diff options
Diffstat (limited to 'crypto/src/security/PrivateKeyFactory.cs')
-rw-r--r-- | crypto/src/security/PrivateKeyFactory.cs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/crypto/src/security/PrivateKeyFactory.cs b/crypto/src/security/PrivateKeyFactory.cs index dfc73c2cd..408c8b6a0 100644 --- a/crypto/src/security/PrivateKeyFactory.cs +++ b/crypto/src/security/PrivateKeyFactory.cs @@ -174,26 +174,26 @@ namespace Org.BouncyCastle.Security } else if (algOid.Equals(EdECObjectIdentifiers.id_X25519)) { - return new X25519PrivateKeyParameters(GetRawKey(keyInfo, X25519PrivateKeyParameters.KeySize), 0); + return new X25519PrivateKeyParameters(GetRawKey(keyInfo)); } else if (algOid.Equals(EdECObjectIdentifiers.id_X448)) { - return new X448PrivateKeyParameters(GetRawKey(keyInfo, X448PrivateKeyParameters.KeySize), 0); + return new X448PrivateKeyParameters(GetRawKey(keyInfo)); } else if (algOid.Equals(EdECObjectIdentifiers.id_Ed25519)) { - return new Ed25519PrivateKeyParameters(GetRawKey(keyInfo, Ed25519PrivateKeyParameters.KeySize), 0); + return new Ed25519PrivateKeyParameters(GetRawKey(keyInfo)); } else if (algOid.Equals(EdECObjectIdentifiers.id_Ed448)) { - return new Ed448PrivateKeyParameters(GetRawKey(keyInfo, Ed448PrivateKeyParameters.KeySize), 0); + return new Ed448PrivateKeyParameters(GetRawKey(keyInfo)); } else if (algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_512) || algOid.Equals(RosstandartObjectIdentifiers.id_tc26_gost_3410_12_256)) { Gost3410PublicKeyAlgParameters gostParams = Gost3410PublicKeyAlgParameters.GetInstance(keyInfo.PrivateKeyAlgorithm.Parameters); - ECGost3410Parameters ecSpec = null; - BigInteger d = null; + ECGost3410Parameters ecSpec; + BigInteger d; Asn1Object p = keyInfo.PrivateKeyAlgorithm.Parameters.ToAsn1Object(); if (p is Asn1Sequence && (Asn1Sequence.GetInstance(p).Count == 2 || Asn1Sequence.GetInstance(p).Count == 3)) { @@ -280,13 +280,9 @@ namespace Org.BouncyCastle.Security } } - private static byte[] GetRawKey(PrivateKeyInfo keyInfo, int expectedSize) + private static byte[] GetRawKey(PrivateKeyInfo keyInfo) { - byte[] result = Asn1OctetString.GetInstance(keyInfo.ParsePrivateKey()).GetOctets(); - if (expectedSize != result.Length) - throw new SecurityUtilityException("private key encoding has incorrect length"); - - return result; + return Asn1OctetString.GetInstance(keyInfo.ParsePrivateKey()).GetOctets(); } public static AsymmetricKeyParameter DecryptKey( |