use of com.google.crypto.tink.proto.OutputPrefixType in project tink by google.
the class KeysetManager method newKey.
@GuardedBy("this")
private synchronized Keyset.Key newKey(KeyTemplate keyTemplate) throws GeneralSecurityException {
KeyData keyData = Registry.newKeyData(keyTemplate);
int keyId = newKeyId();
OutputPrefixType outputPrefixType = keyTemplate.getOutputPrefixType();
if (outputPrefixType == OutputPrefixType.UNKNOWN_PREFIX) {
outputPrefixType = OutputPrefixType.TINK;
}
return Keyset.Key.newBuilder().setKeyData(keyData).setKeyId(keyId).setStatus(KeyStatusType.ENABLED).setOutputPrefixType(outputPrefixType).build();
}
use of com.google.crypto.tink.proto.OutputPrefixType in project tink by google.
the class SignatureKeyTemplatesTest method createEcdsaKeyTemplate.
@Test
public void createEcdsaKeyTemplate() throws Exception {
// Intentionally using "weird" or invalid values for parameters,
// to test that the function correctly puts them in the resulting template.
HashType hashType = HashType.SHA512;
EllipticCurveType curve = EllipticCurveType.UNKNOWN_CURVE;
EcdsaSignatureEncoding encoding = EcdsaSignatureEncoding.IEEE_P1363;
OutputPrefixType prefixType = OutputPrefixType.TINK;
KeyTemplate template = SignatureKeyTemplates.createEcdsaKeyTemplate(hashType, curve, encoding, prefixType);
assertEquals(new EcdsaSignKeyManager().getKeyType(), template.getTypeUrl());
assertEquals(OutputPrefixType.TINK, template.getOutputPrefixType());
EcdsaKeyFormat format = EcdsaKeyFormat.parseFrom(template.getValue(), ExtensionRegistryLite.getEmptyRegistry());
assertEquals(hashType, format.getParams().getHashType());
assertEquals(curve, format.getParams().getCurve());
assertEquals(encoding, format.getParams().getEncoding());
}
Aggregations