Search in sources :

Example 6 with EciesAeadHkdfParams

use of com.google.crypto.tink.proto.EciesAeadHkdfParams in project tink by google.

the class EciesAeadHkdfPublicKeyManager method getPrimitive.

/**
 * @param recipientKey {@code EciesAeadHkdfPublicKey} proto
 */
@Override
public HybridEncrypt getPrimitive(MessageLite recipientKey) throws GeneralSecurityException {
    if (!(recipientKey instanceof EciesAeadHkdfPublicKey)) {
        throw new GeneralSecurityException("expected EciesAeadHkdfPublicKey proto");
    }
    EciesAeadHkdfPublicKey recipientKeyProto = (EciesAeadHkdfPublicKey) recipientKey;
    validate(recipientKeyProto);
    EciesAeadHkdfParams eciesParams = recipientKeyProto.getParams();
    EciesHkdfKemParams kemParams = eciesParams.getKemParams();
    ECPublicKey recipientPublicKey = EllipticCurves.getEcPublicKey(HybridUtil.toCurveType(kemParams.getCurveType()), recipientKeyProto.getX().toByteArray(), recipientKeyProto.getY().toByteArray());
    EciesAeadHkdfDemHelper demHelper = new RegistryEciesAeadHkdfDemHelper(eciesParams.getDemParams().getAeadDem());
    return new EciesAeadHkdfHybridEncrypt(recipientPublicKey, kemParams.getHkdfSalt().toByteArray(), HybridUtil.toHmacAlgo(kemParams.getHkdfHashType()), HybridUtil.toPointFormatType(eciesParams.getEcPointFormat()), demHelper);
}
Also used : EciesAeadHkdfDemHelper(com.google.crypto.tink.subtle.EciesAeadHkdfDemHelper) EciesAeadHkdfParams(com.google.crypto.tink.proto.EciesAeadHkdfParams) ECPublicKey(java.security.interfaces.ECPublicKey) GeneralSecurityException(java.security.GeneralSecurityException) EciesAeadHkdfPublicKey(com.google.crypto.tink.proto.EciesAeadHkdfPublicKey) EciesHkdfKemParams(com.google.crypto.tink.proto.EciesHkdfKemParams) EciesAeadHkdfHybridEncrypt(com.google.crypto.tink.subtle.EciesAeadHkdfHybridEncrypt)

Example 7 with EciesAeadHkdfParams

use of com.google.crypto.tink.proto.EciesAeadHkdfParams in project tink by google.

the class EciesAeadHkdfPublicKeyManagerTest method createKeyFormat.

private EciesAeadHkdfKeyFormat createKeyFormat(EllipticCurveType curve, HashType hashType, EcPointFormat ecPointFormat, KeyTemplate demKeyTemplate, byte[] salt) {
    EciesHkdfKemParams kemParams = EciesHkdfKemParams.newBuilder().setCurveType(curve).setHkdfHashType(hashType).setHkdfSalt(ByteString.copyFrom(salt)).build();
    EciesAeadDemParams demParams = EciesAeadDemParams.newBuilder().setAeadDem(demKeyTemplate).build();
    EciesAeadHkdfParams params = EciesAeadHkdfParams.newBuilder().setKemParams(kemParams).setDemParams(demParams).setEcPointFormat(ecPointFormat).build();
    return EciesAeadHkdfKeyFormat.newBuilder().setParams(params).build();
}
Also used : EciesAeadHkdfParams(com.google.crypto.tink.proto.EciesAeadHkdfParams) EciesAeadDemParams(com.google.crypto.tink.proto.EciesAeadDemParams) EciesHkdfKemParams(com.google.crypto.tink.proto.EciesHkdfKemParams)

Aggregations

EciesAeadHkdfParams (com.google.crypto.tink.proto.EciesAeadHkdfParams)7 EciesHkdfKemParams (com.google.crypto.tink.proto.EciesHkdfKemParams)4 EciesAeadHkdfPrivateKey (com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey)3 EciesAeadHkdfDemHelper (com.google.crypto.tink.subtle.EciesAeadHkdfDemHelper)3 HybridDecrypt (com.google.crypto.tink.HybridDecrypt)2 HybridEncrypt (com.google.crypto.tink.HybridEncrypt)2 EciesAeadHkdfHybridEncrypt (com.google.crypto.tink.subtle.EciesAeadHkdfHybridEncrypt)2 GeneralSecurityException (java.security.GeneralSecurityException)2 ECPublicKey (java.security.interfaces.ECPublicKey)2 ECPoint (java.security.spec.ECPoint)2 Test (org.junit.Test)2 KeysetHandle (com.google.crypto.tink.KeysetHandle)1 EcPointFormat (com.google.crypto.tink.proto.EcPointFormat)1 EciesAeadDemParams (com.google.crypto.tink.proto.EciesAeadDemParams)1 EciesAeadHkdfPublicKey (com.google.crypto.tink.proto.EciesAeadHkdfPublicKey)1 EllipticCurveType (com.google.crypto.tink.proto.EllipticCurveType)1 HashType (com.google.crypto.tink.proto.HashType)1 KeyTemplate (com.google.crypto.tink.proto.KeyTemplate)1 Key (com.google.crypto.tink.proto.Keyset.Key)1 EciesAeadHkdfHybridDecrypt (com.google.crypto.tink.subtle.EciesAeadHkdfHybridDecrypt)1