Search in sources :

Example 1 with AesCtrHmacStreaming

use of com.google.crypto.tink.subtle.AesCtrHmacStreaming in project tink by google.

the class AesCtrHmacStreamingKeyManager method getPrimitive.

/**
 * @param key {@code AesCtrHmacStreamingKey} proto
 */
@Override
public StreamingAead getPrimitive(MessageLite key) throws GeneralSecurityException {
    if (!(key instanceof AesCtrHmacStreamingKey)) {
        throw new GeneralSecurityException("expected AesCtrHmacStreamingKey proto");
    }
    AesCtrHmacStreamingKey keyProto = (AesCtrHmacStreamingKey) key;
    validate(keyProto);
    return new AesCtrHmacStreaming(keyProto.getKeyValue().toByteArray(), StreamingAeadUtil.toHmacAlgo(keyProto.getParams().getHkdfHashType()), keyProto.getParams().getDerivedKeySize(), StreamingAeadUtil.toHmacAlgo(keyProto.getParams().getHmacParams().getHash()), keyProto.getParams().getHmacParams().getTagSize(), keyProto.getParams().getCiphertextSegmentSize(), /* firstSegmentOffset= */
    0);
}
Also used : AesCtrHmacStreaming(com.google.crypto.tink.subtle.AesCtrHmacStreaming) AesCtrHmacStreamingKey(com.google.crypto.tink.proto.AesCtrHmacStreamingKey) GeneralSecurityException(java.security.GeneralSecurityException)

Aggregations

AesCtrHmacStreamingKey (com.google.crypto.tink.proto.AesCtrHmacStreamingKey)1 AesCtrHmacStreaming (com.google.crypto.tink.subtle.AesCtrHmacStreaming)1 GeneralSecurityException (java.security.GeneralSecurityException)1