private SubjectPublicKeyInfo getSenderPublicKeyInfo(AlgorithmIdentifier recKeyAlgId, OriginatorIdentifierOrKey originator) throws CMSException, IOException { OriginatorPublicKey opk = originator.getOriginatorKey(); if (opk != null) { return getPublicKeyInfoFromOriginatorPublicKey(recKeyAlgId, opk); } OriginatorId origID; IssuerAndSerialNumber iAndSN = originator.getIssuerAndSerialNumber(); if (iAndSN != null) { origID = new OriginatorId(iAndSN.getName(), iAndSN.getSerialNumber().getValue()); } else { SubjectKeyIdentifier ski = originator.getSubjectKeyIdentifier(); origID = new OriginatorId(ski.getKeyIdentifier()); } return getPublicKeyInfoFromOriginatorId(origID); }
private MQVuserKeyingMaterial( ASN1Sequence seq) { if (seq.size() != 1 && seq.size() != 2) { throw new IllegalArgumentException("Sequence has incorrect number of elements"); } this.ephemeralPublicKey = OriginatorPublicKey.getInstance( seq.getObjectAt(0)); if (seq.size() > 1) { this.addedukm = ASN1OctetString.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true); } }
public MQVuserKeyingMaterial( OriginatorPublicKey ephemeralPublicKey, ASN1OctetString addedukm) { // TODO Check ephemeralPublicKey not null this.ephemeralPublicKey = ephemeralPublicKey; this.addedukm = addedukm; }
private MQVuserKeyingMaterial( ASN1Sequence seq) { // TODO Check seq has either 1 or 2 elements this.ephemeralPublicKey = OriginatorPublicKey.getInstance( seq.getObjectAt(0)); if (seq.size() > 1) { this.addedukm = ASN1OctetString.getInstance( (ASN1TaggedObject)seq.getObjectAt(1), true); } }
private SubjectPublicKeyInfo getPublicKeyInfoFromOriginatorPublicKey(AlgorithmIdentifier recKeyAlgId, OriginatorPublicKey originatorPublicKey) { SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo( recKeyAlgId, originatorPublicKey.getPublicKey().getBytes()); return pubInfo; }
public MQVuserKeyingMaterial( OriginatorPublicKey ephemeralPublicKey, ASN1OctetString addedukm) { if (ephemeralPublicKey == null) { throw new IllegalArgumentException("Ephemeral public key cannot be null"); } this.ephemeralPublicKey = ephemeralPublicKey; this.addedukm = addedukm; }
protected byte[] getUserKeyingMaterial(AlgorithmIdentifier keyAgreeAlg) throws CMSException { init(keyAgreeAlg.getAlgorithm()); if (ephemeralKP != null) { OriginatorPublicKey originatorPublicKey = createOriginatorPublicKey(SubjectPublicKeyInfo.getInstance(ephemeralKP.getPublic().getEncoded())); try { if (userKeyingMaterial != null) { return new MQVuserKeyingMaterial(originatorPublicKey, new DEROctetString(userKeyingMaterial)).getEncoded(); } else { return new MQVuserKeyingMaterial(originatorPublicKey, null).getEncoded(); } } catch (IOException e) { throw new CMSException("unable to encode user keying material: " + e.getMessage(), e); } } return userKeyingMaterial; }
public OriginatorPublicKey getEphemeralPublicKey() { return ephemeralPublicKey; }
protected OriginatorPublicKey createOriginatorPublicKey(SubjectPublicKeyInfo originatorKeyInfo) { return new OriginatorPublicKey( new AlgorithmIdentifier(originatorKeyInfo.getAlgorithm().getAlgorithm(), DERNull.INSTANCE), originatorKeyInfo.getPublicKeyData().getBytes()); }