public byte[] createKey(ASN1ObjectIdentifier curveOID, ECPoint s, byte[] recipientFingerPrint) throws PGPException { try { // RFC 6637 - Section 8 // curve_OID_len = (byte)len(curve_OID); // Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 // || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous // Sender " || recipient_fingerprint; // Z_len = the key size for the KEK_alg_ID used with AESKeyWrap // Compute Z = KDF( S, Z_len, Param ); ByteArrayOutputStream pOut = new ByteArrayOutputStream(); byte[] encOid = curveOID.getEncoded(); pOut.write(encOid, 1, encOid.length - 1); pOut.write(PublicKeyAlgorithmTags.ECDH); pOut.write(0x03); pOut.write(0x01); pOut.write(digCalc.getAlgorithm()); pOut.write(keyAlgorithm); pOut.write(ANONYMOUS_SENDER); pOut.write(recipientFingerPrint); return KDF(digCalc, s, getKeyLen(keyAlgorithm), pOut.toByteArray()); } catch (IOException e) { throw new PGPException("Exception performing KDF: " + e.getMessage(), e); } }
public static byte[] createUserKeyingMaterial(PublicKeyPacket pubKeyData, KeyFingerPrintCalculator fingerPrintCalculator) throws IOException, PGPException { ByteArrayOutputStream pOut = new ByteArrayOutputStream(); ECDHPublicBCPGKey ecKey = (ECDHPublicBCPGKey)pubKeyData.getKey(); byte[] encOid = ecKey.getCurveOID().getEncoded(); pOut.write(encOid, 1, encOid.length - 1); pOut.write(pubKeyData.getAlgorithm()); pOut.write(0x03); pOut.write(0x01); pOut.write(ecKey.getHashAlgorithm()); pOut.write(ecKey.getSymmetricKeyAlgorithm()); pOut.write(ANONYMOUS_SENDER); pOut.write(fingerPrintCalculator.calculateFingerprint(pubKeyData)); return pOut.toByteArray(); } }
void encode(ASN1OutputStream out) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (directReference != null) { baos.write(directReference.getEncoded(ASN1Encoding.DER)); } if (indirectReference != null) { baos.write(indirectReference.getEncoded(ASN1Encoding.DER)); } if (dataValueDescriptor != null) { baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DER)); } DERTaggedObject obj = new DERTaggedObject(true, encoding, externalContent); baos.write(obj.getEncoded(ASN1Encoding.DER)); out.writeEncoded(BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray()); }
void encode(ASN1OutputStream out) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (directReference != null) { baos.write(directReference.getEncoded(ASN1Encoding.DER)); } if (indirectReference != null) { baos.write(indirectReference.getEncoded(ASN1Encoding.DER)); } if (dataValueDescriptor != null) { baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DER)); } DERTaggedObject obj = new DERTaggedObject(true, encoding, externalContent); baos.write(obj.getEncoded(ASN1Encoding.DER)); out.writeEncoded(BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray()); }
public void encode( BCPGOutputStream out) throws IOException { byte[] oid = this.oid.getEncoded(); out.write(oid, 1, oid.length - 1); MPInteger point = new MPInteger(this.point); out.writeObject(point); }