use of com.google.crypto.tink.subtle.EciesAeadHkdfDemHelper in project tink by google.
the class EciesAeadHkdfPrivateKeyManager method getPrimitive.
/**
* @param recipientKey {@code EciesAeadHkdfPrivateKey} proto
*/
@Override
public HybridDecrypt getPrimitive(MessageLite recipientKey) throws GeneralSecurityException {
if (!(recipientKey instanceof EciesAeadHkdfPrivateKey)) {
throw new GeneralSecurityException("expected EciesAeadHkdfPrivateKey proto");
}
EciesAeadHkdfPrivateKey recipientKeyProto = (EciesAeadHkdfPrivateKey) recipientKey;
validate(recipientKeyProto);
EciesAeadHkdfParams eciesParams = recipientKeyProto.getPublicKey().getParams();
EciesHkdfKemParams kemParams = eciesParams.getKemParams();
ECPrivateKey recipientPrivateKey = EllipticCurves.getEcPrivateKey(HybridUtil.toCurveType(kemParams.getCurveType()), recipientKeyProto.getKeyValue().toByteArray());
EciesAeadHkdfDemHelper demHelper = new RegistryEciesAeadHkdfDemHelper(eciesParams.getDemParams().getAeadDem());
return new EciesAeadHkdfHybridDecrypt(recipientPrivateKey, kemParams.getHkdfSalt().toByteArray(), HybridUtil.toHmacAlgo(kemParams.getHkdfHashType()), HybridUtil.toPointFormatType(eciesParams.getEcPointFormat()), demHelper);
}
use of com.google.crypto.tink.subtle.EciesAeadHkdfDemHelper 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);
}
Aggregations