Search in sources :

Example 26 with RsaSsaPkcs1KeyFormat

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

the class RsaSsaPkcs1SignKeyManagerTest method createKey_largeKey.

@Test
public void createKey_largeKey() throws Exception {
    if (TestUtil.isTsan()) {
        // factory.createKey is too slow in Tsan.
        return;
    }
    RsaSsaPkcs1KeyFormat format = createKeyFormat(HashType.SHA512, 4096, RSAKeyGenParameterSpec.F4);
    RsaSsaPkcs1PrivateKey key = factory.createKey(format);
    checkConsistency(key, format);
    checkKey(key);
}
Also used : RsaSsaPkcs1PrivateKey(com.google.crypto.tink.proto.RsaSsaPkcs1PrivateKey) RsaSsaPkcs1KeyFormat(com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat) Test(org.junit.Test)

Example 27 with RsaSsaPkcs1KeyFormat

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

the class SignatureKeyTemplates method createRsaSsaPkcs1KeyTemplate.

/**
 * @return a {@link KeyTemplate} containing a {@link RsaSsaPkcs1KeyFormat} with some specified
 *     parameters.
 */
public static KeyTemplate createRsaSsaPkcs1KeyTemplate(HashType hashType, int modulusSize, BigInteger publicExponent, OutputPrefixType prefixType) {
    RsaSsaPkcs1Params params = RsaSsaPkcs1Params.newBuilder().setHashType(hashType).build();
    RsaSsaPkcs1KeyFormat format = RsaSsaPkcs1KeyFormat.newBuilder().setParams(params).setModulusSizeInBits(modulusSize).setPublicExponent(ByteString.copyFrom(publicExponent.toByteArray())).build();
    return KeyTemplate.newBuilder().setValue(format.toByteString()).setTypeUrl(new RsaSsaPkcs1SignKeyManager().getKeyType()).setOutputPrefixType(prefixType).build();
}
Also used : RsaSsaPkcs1Params(com.google.crypto.tink.proto.RsaSsaPkcs1Params) RsaSsaPkcs1KeyFormat(com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat)

Aggregations

RsaSsaPkcs1KeyFormat (com.google.crypto.tink.proto.RsaSsaPkcs1KeyFormat)27 Test (org.junit.Test)25 RsaSsaPkcs1PrivateKey (com.google.crypto.tink.proto.RsaSsaPkcs1PrivateKey)9 BigInteger (java.math.BigInteger)8 RsaSsaPkcs1PublicKey (com.google.crypto.tink.proto.RsaSsaPkcs1PublicKey)5 KeyTemplate (com.google.crypto.tink.KeyTemplate)4 PublicKeySign (com.google.crypto.tink.PublicKeySign)4 PublicKeyVerify (com.google.crypto.tink.PublicKeyVerify)3 ByteString (com.google.protobuf.ByteString)3 KeyTemplate (com.google.crypto.tink.proto.KeyTemplate)2 RsaSsaPkcs1Params (com.google.crypto.tink.proto.RsaSsaPkcs1Params)2 RSAPublicKey (java.security.interfaces.RSAPublicKey)2 RsaSsaPkcs1VerifyJce (com.google.crypto.tink.subtle.RsaSsaPkcs1VerifyJce)1 KeyFactory (java.security.KeyFactory)1 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 RSAPrivateCrtKey (java.security.interfaces.RSAPrivateCrtKey)1 RSAKeyGenParameterSpec (java.security.spec.RSAKeyGenParameterSpec)1 RSAPublicKeySpec (java.security.spec.RSAPublicKeySpec)1 HashMap (java.util.HashMap)1