public void configure(ConfigurableProvider provider) { provider.addAlgorithm("KeyFactory.ECGOST3410", PREFIX + "KeyFactorySpi"); provider.addAlgorithm("Alg.Alias.KeyFactory.GOST-3410-2001", "ECGOST3410"); provider.addAlgorithm("Alg.Alias.KeyFactory.ECGOST-3410", "ECGOST3410"); registerOid(provider, CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410", new KeyFactorySpi()); registerOidAlgorithmParameters(provider, CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410"); provider.addAlgorithm("KeyPairGenerator.ECGOST3410", PREFIX + "KeyPairGeneratorSpi"); provider.addAlgorithm("Alg.Alias.KeyPairGenerator.ECGOST-3410", "ECGOST3410"); provider.addAlgorithm("Alg.Alias.KeyPairGenerator.GOST-3410-2001", "ECGOST3410"); provider.addAlgorithm("Signature.ECGOST3410", PREFIX + "SignatureSpi"); provider.addAlgorithm("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410"); provider.addAlgorithm("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410"); addSignatureAlgorithm(provider, "GOST3411", "ECGOST3410", PREFIX + "SignatureSpi", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001); }
DefaultSecretKeyProvider() { Map keySizes = new HashMap(); keySizes.put(new ASN1ObjectIdentifier("1.2.840.113533.7.66.10"), Integers.valueOf(128)); keySizes.put(PKCSObjectIdentifiers.des_EDE3_CBC, Integers.valueOf(192)); keySizes.put(NISTObjectIdentifiers.id_aes128_CBC, Integers.valueOf(128)); keySizes.put(NISTObjectIdentifiers.id_aes192_CBC, Integers.valueOf(192)); keySizes.put(NISTObjectIdentifiers.id_aes256_CBC, Integers.valueOf(256)); keySizes.put(NTTObjectIdentifiers.id_camellia128_cbc, Integers.valueOf(128)); keySizes.put(NTTObjectIdentifiers.id_camellia192_cbc, Integers.valueOf(192)); keySizes.put(NTTObjectIdentifiers.id_camellia256_cbc, Integers.valueOf(256)); keySizes.put(CryptoProObjectIdentifiers.gostR28147_gcfb, Integers.valueOf(256)); KEY_SIZES = Collections.unmodifiableMap(keySizes); }
DefaultSecretKeyProvider() { Map keySizes = new HashMap(); keySizes.put(new ASN1ObjectIdentifier("1.2.840.113533.7.66.10"), Integers.valueOf(128)); keySizes.put(PKCSObjectIdentifiers.des_EDE3_CBC.getId(), Integers.valueOf(192)); keySizes.put(NISTObjectIdentifiers.id_aes128_CBC, Integers.valueOf(128)); keySizes.put(NISTObjectIdentifiers.id_aes192_CBC, Integers.valueOf(192)); keySizes.put(NISTObjectIdentifiers.id_aes256_CBC, Integers.valueOf(256)); keySizes.put(NTTObjectIdentifiers.id_camellia128_cbc, Integers.valueOf(128)); keySizes.put(NTTObjectIdentifiers.id_camellia192_cbc, Integers.valueOf(192)); keySizes.put(NTTObjectIdentifiers.id_camellia256_cbc, Integers.valueOf(256)); keySizes.put(CryptoProObjectIdentifiers.gostR28147_gcfb, Integers.valueOf(256)); KEY_SIZES = Collections.unmodifiableMap(keySizes); }
public GOST3410ParameterSpec( GOST3410PublicKeyParameterSetSpec spec) { this.keyParameters = spec; this.digestParamSetOID = CryptoProObjectIdentifiers.gostR3411_94_CryptoProParamSet.getId(); this.encryptionParamSetOID = null; }
public void configure(ConfigurableProvider provider) { provider.addAlgorithm("Cipher.GOST28147", PREFIX + "$ECB"); provider.addAlgorithm("Alg.Alias.Cipher.GOST", "GOST28147"); provider.addAlgorithm("Alg.Alias.Cipher.GOST-28147", "GOST28147"); provider.addAlgorithm("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, PREFIX + "$CBC"); provider.addAlgorithm("KeyGenerator.GOST28147", PREFIX + "$KeyGen"); provider.addAlgorithm("Alg.Alias.KeyGenerator.GOST", "GOST28147"); provider.addAlgorithm("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147"); provider.addAlgorithm("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147"); provider.addAlgorithm("Mac.GOST28147MAC", PREFIX + "$Mac"); provider.addAlgorithm("Alg.Alias.Mac.GOST28147", "GOST28147MAC"); }
public void configure(ConfigurableProvider provider) { provider.addAlgorithm("MessageDigest.GOST3411", PREFIX + "$Digest"); provider.addAlgorithm("Alg.Alias.MessageDigest.GOST", "GOST3411"); provider.addAlgorithm("Alg.Alias.MessageDigest.GOST-3411", "GOST3411"); provider.addAlgorithm("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411"); addHMACAlgorithm(provider, "GOST3411", PREFIX + "$HashMac", PREFIX + "$KeyGenerator"); addHMACAlias(provider, "GOST3411", CryptoProObjectIdentifiers.gostR3411); }
public PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getPrivateKeyAlgorithm().getAlgorithm(); if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) { return new BCGOST3410PrivateKey(keyInfo); } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } }
public PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getAlgorithm().getAlgorithm(); if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) { return new BCGOST3410PublicKey(keyInfo); } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } }
public KeyPair generateKeyPair() { if (!initialised) { init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom()); } AsymmetricCipherKeyPair pair = engine.generateKeyPair(); GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters)pair.getPublic(); GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate(); return new KeyPair(new BCGOST3410PublicKey(pub, gost3410Params), new BCGOST3410PrivateKey(priv, gost3410Params)); }
public void configure(ConfigurableProvider provider) { provider.addAlgorithm("KeyPairGenerator.GOST3410", PREFIX + "KeyPairGeneratorSpi"); provider.addAlgorithm("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410"); provider.addAlgorithm("KeyFactory.GOST3410", PREFIX + "KeyFactorySpi"); provider.addAlgorithm("Alg.Alias.KeyFactory.GOST-3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410"); provider.addAlgorithm("AlgorithmParameters.GOST3410", PREFIX + "AlgorithmParametersSpi"); provider.addAlgorithm("AlgorithmParameterGenerator.GOST3410", PREFIX + "AlgorithmParameterGeneratorSpi"); registerOid(provider, CryptoProObjectIdentifiers.gostR3410_94, "GOST3410", new KeyFactorySpi()); registerOidAlgorithmParameters(provider, CryptoProObjectIdentifiers.gostR3410_94, "GOST3410"); provider.addAlgorithm("Signature.GOST3410", PREFIX + "SignatureSpi"); provider.addAlgorithm("Alg.Alias.Signature.GOST-3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.Signature.GOST-3410-94", "GOST3410"); provider.addAlgorithm("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410"); provider.addAlgorithm("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410"); provider.addAlgorithm("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410"); }
public PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getPrivateKeyAlgorithm().getAlgorithm(); if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) { return new BCECGOST3410PrivateKey(keyInfo); } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } }
public PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws IOException { ASN1ObjectIdentifier algOid = keyInfo.getAlgorithm().getAlgorithm(); if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) { return new BCECGOST3410PublicKey(keyInfo); } else { throw new IOException("algorithm identifier " + algOid + " in key not recognised"); } }
public void configure(ConfigurableProvider provider) { provider.addAlgorithm("Cipher.GOST28147", PREFIX + "$ECB"); provider.addAlgorithm("Alg.Alias.Cipher.GOST", "GOST28147"); provider.addAlgorithm("Alg.Alias.Cipher.GOST-28147", "GOST28147"); provider.addAlgorithm("Cipher." + CryptoProObjectIdentifiers.gostR28147_gcfb, PREFIX + "$GCFB"); provider.addAlgorithm("KeyGenerator.GOST28147", PREFIX + "$KeyGen"); provider.addAlgorithm("Alg.Alias.KeyGenerator.GOST", "GOST28147"); provider.addAlgorithm("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147"); provider.addAlgorithm("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_gcfb, "GOST28147"); provider.addAlgorithm("Mac.GOST28147MAC", PREFIX + "$Mac"); provider.addAlgorithm("Alg.Alias.Mac.GOST28147", "GOST28147MAC"); }
private int getDigestCode(ASN1ObjectIdentifier algorithm) throws InvalidKeySpecException { if (algorithm.equals(CryptoProObjectIdentifiers.gostR3411Hmac)) { return GOST3411; } else if (algorithm.equals(PKCSObjectIdentifiers.id_hmacWithSHA1)) { return SHA1; } throw new InvalidKeySpecException("Invalid KeySpec: unknown PRF algorithm " + algorithm); }
public void configure(ConfigurableProvider provider) { provider.addAlgorithm("MessageDigest.GOST3411", PREFIX + "$Digest"); provider.addAlgorithm("Alg.Alias.MessageDigest.GOST", "GOST3411"); provider.addAlgorithm("Alg.Alias.MessageDigest.GOST-3411", "GOST3411"); provider.addAlgorithm("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411"); provider.addAlgorithm("SecretKeyFactory.PBEWITHHMACGOST3411", PREFIX + "$PBEWithMacKeyFactory"); provider.addAlgorithm("Alg.Alias.SecretKeyFactory." + CryptoProObjectIdentifiers.gostR3411, "PBEWITHHMACGOST3411"); addHMACAlgorithm(provider, "GOST3411", PREFIX + "$HashMac", PREFIX + "$KeyGenerator"); addHMACAlias(provider, "GOST3411", CryptoProObjectIdentifiers.gostR3411); }
private void oidTest() { String[] oids = { CryptoProObjectIdentifiers.gostR28147_gcfb.getId(), }; String[] names = { "GOST28147/GCFB/NoPadding" }; try { byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; IvParameterSpec ivSpec = new IvParameterSpec(new byte[8]); for (int i = 0; i != oids.length; i++) { Cipher c1 = Cipher.getInstance(oids[i], "BC"); Cipher c2 = Cipher.getInstance(names[i], "BC"); KeyGenerator kg = KeyGenerator.getInstance(oids[i], "BC"); SecretKey k = kg.generateKey(); c1.init(Cipher.ENCRYPT_MODE, k, ivSpec); c2.init(Cipher.DECRYPT_MODE, k, ivSpec); byte[] result = c2.doFinal(c1.doFinal(data)); if (!areEqual(data, result)) { fail("failed OID test"); } } } catch (Exception ex) { fail("failed exception " + ex.toString(), ex); } }
public void testGOST3411WithGOST3410() throws Exception { MimeMultipart smm = generateMultiPartGost(msg); SMIMESigned s = new SMIMESigned(smm); assertEquals("gostr3411-94", getMicAlg(smm)); assertEquals(getDigestOid(s.getSignerInfos()), CryptoProObjectIdentifiers.gostR3411.getId()); verifyMessageBytes(msg, s.getContent()); verifySigners(s.getCertificates(), s.getSignerInfos()); }