public void TestEd448Consistency() { byte[] sk = new byte[Ed448.SecretKeySize]; byte[] pk = new byte[Ed448.PublicKeySize]; byte[] ctx = new byte[Random.NextInt() & 7]; byte[] m = new byte[255]; byte[] sig1 = new byte[Ed448.SignatureSize]; byte[] sig2 = new byte[Ed448.SignatureSize]; Random.NextBytes(ctx); Random.NextBytes(m); for (int i = 0; i < 10; ++i) { Random.NextBytes(sk); Ed448.GeneratePublicKey(sk, 0, pk, 0); int mLen = Random.NextInt() & 255; Ed448.Sign(sk, 0, ctx, m, 0, mLen, sig1, 0); Ed448.Sign(sk, 0, pk, 0, ctx, m, 0, mLen, sig2, 0); Assert.IsTrue(Arrays.AreEqual(sig1, sig2), "Ed448 consistent signatures #" + i); bool shouldVerify = Ed448.Verify(sig1, 0, pk, 0, ctx, m, 0, mLen); Assert.IsTrue(shouldVerify, "Ed448 consistent sign/verify #" + i); sig1[Ed448.PublicKeySize - 1] ^= 0x80; bool shouldNotVerify = Ed448.Verify(sig1, 0, pk, 0, ctx, m, 0, mLen); Assert.IsFalse(shouldNotVerify, "Ed448 consistent verification failure #" + i); } }
private static void CheckEd448Vector(string sSK, string sPK, string sM, string sCTX, string sSig, string text) { byte[] sk = Hex.Decode(sSK); byte[] pk = Hex.Decode(sPK); byte[] pkGen = new byte[Ed448.PublicKeySize]; Ed448.GeneratePublicKey(sk, 0, pkGen, 0); Assert.IsTrue(Arrays.AreEqual(pk, pkGen), text); byte[] m = Hex.Decode(sM); byte[] ctx = Hex.Decode(sCTX); byte[] sig = Hex.Decode(sSig); byte[] sigGen = new byte[Ed448.SignatureSize]; byte[] badsig = Arrays.Clone(sig); badsig[Ed448.SignatureSize - 1] ^= 0x80; Ed448.Sign(sk, 0, ctx, m, 0, m.Length, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); Ed448.Sign(sk, 0, pk, 0, ctx, m, 0, m.Length, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); bool shouldVerify = Ed448.Verify(sig, 0, pk, 0, ctx, m, 0, m.Length); Assert.IsTrue(shouldVerify, text); bool shouldNotVerify = Ed448.Verify(badsig, 0, pk, 0, ctx, m, 0, m.Length); Assert.IsFalse(shouldNotVerify, text); }
/// <summary> /// Try get algorithm from mechanism. /// </summary> /// <param name="mechanism">Algorithm mechanism.</param> /// <param name="algorithm">Algorithm.</param> /// <returns></returns> public static bool TryGetAlgorithm(string mechanism, out IAsymmetricAlgorithm algorithm) { mechanism = mechanism.Replace('_', '-').ToUpperInvariant(); switch (mechanism) { case "DSA": algorithm = DSA; return(true); case "ECDSA": algorithm = ECDSA; return(true); case "ECGOST3410": case "ECGOST3410-2001": case "ECGOST-3410": case "ECGOST-3410-2001": algorithm = ECGOST3410; return(true); case "ED25519": algorithm = new Ed25519(); return(true); case "ED448": algorithm = new Ed448(); return(true); case "ELGAMAL": algorithm = (IAsymmetricAlgorithm)ElGamal; return(true); case "GOST3410": case "GOST3410-94": case "GOST-3410": case "GOST-3410-94": algorithm = GOST3410; return(true); case "RSA": algorithm = (IAsymmetricAlgorithm)RSA; return(true); case "SM2": algorithm = SM2; return(true); default: algorithm = null; return(false); } }
public void Sign(Ed448.Algorithm algorithm, byte[] ctx, byte[] msg, int msgOff, int msgLen, byte[] sig, int sigOff) { Ed448PublicKeyParameters publicKey = GeneratePublicKey(); byte[] pk = new byte[Ed448.PublicKeySize]; publicKey.Encode(pk, 0); switch (algorithm) { case Ed448.Algorithm.Ed448: { Ed448.Sign(data, 0, pk, 0, ctx, msg, msgOff, msgLen, sig, sigOff); break; } case Ed448.Algorithm.Ed448ph: { if (Ed448.PrehashSize != msgLen) { throw new ArgumentException("msgLen"); } Ed448.SignPrehash(data, 0, pk, 0, ctx, msg, msgOff, sig, sigOff); break; } default: { throw new ArgumentException("algorithm"); } } }
public virtual bool VerifySignature(byte[] signature) { if (forSigning) { throw new InvalidOperationException("Ed448phSigner not initialised for verification"); } byte[] pk = publicKey.GetEncoded(); return(Ed448.VerifyPrehash(signature, 0, pk, 0, context, prehash)); }
internal bool VerifySignature(Ed448PublicKeyParameters publicKey, byte[] ctx, byte[] signature) { #if PORTABLE byte[] buf = ToArray(); int count = buf.Length; #else byte[] buf = GetBuffer(); int count = (int)Position; #endif byte[] pk = publicKey.GetEncoded(); bool result = Ed448.Verify(signature, 0, pk, 0, ctx, buf, 0, count); Reset(); return(result); }
public static void ScalarMultBase(byte[] k, int kOff, byte[] r, int rOff) { uint[] x = X448Field.Create(); uint[] y = X448Field.Create(); Ed448.ScalarMultBaseXY(k, kOff, x, y); X448Field.Inv(x, x); X448Field.Mul(x, y, x); X448Field.Sqr(x, x); X448Field.Normalize(x); X448Field.Encode(x, r, rOff); }
public Ed448PublicKeyParameters GeneratePublicKey() { lock (data) { if (null == cachedPublicKey) { byte[] publicKey = new byte[Ed448.PublicKeySize]; Ed448.GeneratePublicKey(data, 0, publicKey, 0); cachedPublicKey = new Ed448PublicKeyParameters(publicKey, 0); } return(cachedPublicKey); } }
public virtual bool VerifySignature(byte[] signature) { if (forSigning || null == publicKey) { throw new InvalidOperationException("Ed448phSigner not initialised for verification"); } if (Ed448.SignatureSize != signature.Length) { prehash.Reset(); return(false); } byte[] pk = publicKey.GetEncoded(); return(Ed448.VerifyPrehash(signature, 0, pk, 0, context, prehash)); }
public void TestPublicKeyValidationPartial() { Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Neutral, 0)); byte[] sk = new byte[Ed448.SecretKeySize]; byte[] pk = new byte[Ed448.PublicKeySize]; for (int i = 0; i < 10; ++i) { Random.NextBytes(sk); Ed448.GeneratePublicKey(sk, 0, pk, 0); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(pk, 0)); } Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000081"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("C784B7238BDDDB84C44FB80936FB103FCF39C1F74EE83163A57DB4AD3946FDC81BF0504D6EC1DBABABDB750997BCA465D5FCD3A45F8E183D00"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("149578BCA53F7D199B472D6D367D22A35942BBCA2051F833122D4DC12FE758A16D672A54D5F8C390C44C2F8B32F21121DA69E9DE8FF9675780"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("9E9F6E7A8576E8D7C286C493FE76559419012B164589DF764E735CFFDE21BFCAF4D7553F9B37178A2F20C77473E4195E3E1E327F3174C14500"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("1979BDCBE0CEC16602B87257114059029605C720D5AFD2A90EF4B06655B34B561EBA6C1034452C3D8D1DA41C57340B0C9A95297E712CA75C00"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("E2B8507036D478F262A7009734CDD383734002CE32397FEA22BFEDEE0CEBB0064D176FB45A05AF19F8B18B07EE20D6E2320D075E95DAF15200"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("3C2FFFFCF504A0EBD8051B3962546C39410464A9C44DC3E82FA9437F2450F0F93C892F28E2ABDF7EA84B051E5536CCA6B44762D0941C5D0700"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("997FE46037CF6207B27B6D0BB9D7D97A038D5BFCF898D07EE6ED07953F0889CC4745D1E018EB7A894EFE88871004452E99C6A344362DA6E080"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("F67C319B8EDCE2E85D450BE46E1671183EB499CE8ABE56BCF666C13A99C5ECBC89FCE9B3B578E2A5D061D3590506BC27614DB6B0C682971B80"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("A7776DDD0BD52EC4D017478E38700395F9F4C45A3BEFFE4EA9994EA1A9E92D8D1CC56539BF57FF88401BBDC764904BC0E3635AEE1721FD3380"), 0)); Assert.IsFalse(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("9F914CD9920D2B75ADBF34F758DA39BB35D1C81B5C480571A7A8B2CAAD7BA0F32D13AF9C69B0BECE5775B324DC49C063354EA2F6F231A23800"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("2E0ACAB5953BC2F22C557C75E6B86225BE9CB3E82E78FC886EB57B628229C0C9548CD82630483C03D0E5DC02B2C3B1BD0E5DEE0B8DE4A88000"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("0F89D2E413A36A33031329169EFAAE88D8F84E90E741C3DFBB01C32544D995FF6EB354B6C5C29E62ACC124E806540C46CB0C0ED71931B39D00"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("AB553809FE1B027328EC7DBE71929C1F3A435B74CC0C06BEA831BC5E287EF2ACF4E831EC8E0C964A80BF85B966D32CADAE8E17E12EAFD3AF80"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("3043631378826937A822BDB8878DC33B9174BEC3530B2A8A4048F6B06B378DBC450E34ED623E47B1449E7636DAFB72F584605EF3BE01647F00"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("8A03959C8BD20BA7B1DA92A4C5591BC846F4CD8BE07387B325E179BB12245E17BDDE1AC82E9F7CAB2A79DDDBE68F8BA8DB7F03F91156C24A00"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("46299C8D31BAFEBBCF1719A851123CC4722E5BE9D93D8F98C215D34082AF658C570B4CFD44079993CBC19B0EAD3BFD0DFB2B67EBABB119B780"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("81A58C03708DD60BD68237622EC9934E8DE27FE7997F74A501B06C60C8F9D68856E7D12B88F1507E29EB0C30531B5AA353F154F2551AF5E580"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("DC5028F5AA0B9217B40C7FE00E10503C37B6611BA87CDD70F01536E87AD659711BA1265E679F94EC8D5ED87476CE031D14B2C7E46268F11A80"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("910DDFE36AAB6DCB7D5B72E6F2DF0769AD86665262232C487F722FEA85429DE247D1EBBC5C579A01D04672894E2B0F3FBDF22B43EA191DF700"), 0)); Assert.IsTrue(Ed448.ValidatePublicKeyPartial(Hex.DecodeStrict("43482D0750D4830AAAF578346288050EAE8ADF96DF66F243E73252114E432B448730517FD8726871508CAD7ECECFDB33120CA5558788B6C800"), 0)); }
public void TestEd448phConsistency() { byte[] sk = new byte[Ed448.SecretKeySize]; byte[] pk = new byte[Ed448.PublicKeySize]; byte[] ctx = new byte[Random.NextInt() & 7]; byte[] m = new byte[255]; byte[] ph = new byte[Ed448.PrehashSize]; byte[] sig1 = new byte[Ed448.SignatureSize]; byte[] sig2 = new byte[Ed448.SignatureSize]; Random.NextBytes(ctx); Random.NextBytes(m); for (int i = 0; i < 10; ++i) { Random.NextBytes(sk); Ed448.GeneratePublicKey(sk, 0, pk, 0); int mLen = Random.NextInt() & 255; IXof prehash = Ed448.CreatePrehash(); prehash.BlockUpdate(m, 0, mLen); prehash.DoFinal(ph, 0, ph.Length); Ed448.SignPrehash(sk, 0, ctx, ph, 0, sig1, 0); Ed448.SignPrehash(sk, 0, pk, 0, ctx, ph, 0, sig2, 0); Assert.IsTrue(Arrays.AreEqual(sig1, sig2), "Ed448ph consistent signatures #" + i); bool shouldVerify = Ed448.VerifyPrehash(sig1, 0, pk, 0, ctx, ph, 0); Assert.IsTrue(shouldVerify, "Ed448ph consistent sign/verify #" + i); sig1[Ed448.PublicKeySize - 1] ^= 0x80; bool shouldNotVerify = Ed448.VerifyPrehash(sig1, 0, pk, 0, ctx, ph, 0); Assert.IsFalse(shouldNotVerify, "Ed448ph consistent verification failure #" + i); } }
private static void CheckEd448phVector(string sSK, string sPK, string sM, string sCTX, string sSig, string text) { byte[] sk = Hex.Decode(sSK); byte[] pk = Hex.Decode(sPK); byte[] pkGen = new byte[Ed448.PublicKeySize]; Ed448.GeneratePublicKey(sk, 0, pkGen, 0); Assert.IsTrue(Arrays.AreEqual(pk, pkGen), text); byte[] m = Hex.Decode(sM); byte[] ctx = Hex.Decode(sCTX); byte[] sig = Hex.Decode(sSig); byte[] badsig = Arrays.Clone(sig); badsig[Ed448.SignatureSize - 1] ^= 0x80; byte[] sigGen = new byte[Ed448.SignatureSize]; { IXof prehash = Ed448.CreatePrehash(); prehash.BlockUpdate(m, 0, m.Length); byte[] ph = new byte[Ed448.PrehashSize]; prehash.DoFinal(ph, 0, ph.Length); Ed448.SignPrehash(sk, 0, ctx, ph, 0, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); Ed448.SignPrehash(sk, 0, pk, 0, ctx, ph, 0, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); bool shouldVerify = Ed448.VerifyPrehash(sig, 0, pk, 0, ctx, ph, 0); Assert.IsTrue(shouldVerify, text); bool shouldNotVerify = Ed448.VerifyPrehash(badsig, 0, pk, 0, ctx, ph, 0); Assert.IsFalse(shouldNotVerify, text); } { IXof ph = Ed448.CreatePrehash(); ph.BlockUpdate(m, 0, m.Length); Ed448.SignPrehash(sk, 0, ctx, ph, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); } { IXof ph = Ed448.CreatePrehash(); ph.BlockUpdate(m, 0, m.Length); Ed448.SignPrehash(sk, 0, pk, 0, ctx, ph, sigGen, 0); Assert.IsTrue(Arrays.AreEqual(sig, sigGen), text); } { IXof ph = Ed448.CreatePrehash(); ph.BlockUpdate(m, 0, m.Length); bool shouldVerify = Ed448.VerifyPrehash(sig, 0, pk, 0, ctx, ph); Assert.IsTrue(shouldVerify, text); } { IXof ph = Ed448.CreatePrehash(); ph.BlockUpdate(m, 0, m.Length); bool shouldNotVerify = Ed448.VerifyPrehash(badsig, 0, pk, 0, ctx, ph); Assert.IsFalse(shouldNotVerify, text); } }
public void SetUp() { Ed448.Precompute(); }
public Ed448PrivateKeyParameters(SecureRandom random) : base(true) { Ed448.GeneratePrivateKey(random, data); }
/// <summary> /// Try get algorithm from mechanism. /// </summary> /// <param name="mechanism">Algorithm mechanism.</param> /// <param name="algorithm">Algorithm.</param> /// <returns></returns> public static bool TryGetAlgorithm(string mechanism, out ISignatureAlgorithm algorithm) { mechanism = mechanism.Replace('_', '-').ToUpperInvariant(); switch (mechanism) { case "SHA1WITHCVC-ECDSA": case "SHA-1WITHCVC-ECDSA": algorithm = SHA1withCVC_ECDSA; return(true); case "SHA224WITHCVC-ECDSA": case "SHA-224WITHCVC-ECDSA": algorithm = SHA224withCVC_ECDSA; return(true); case "SHA256WITHCVC-ECDSA": case "SHA-256WITHCVC-ECDSA": algorithm = SHA256withCVC_ECDSA; return(true); case "SHA384WITHCVC-ECDSA": case "SHA-384WITHCVC-ECDSA": algorithm = SHA384withCVC_ECDSA; return(true); case "SHA512WITHCVC-ECDSA": case "SHA-512WITHCVC-ECDSA": algorithm = SHA512withCVC_ECDSA; return(true); case "ED25519": algorithm = new Ed25519(); return(true); case "ED25519CTX": algorithm = new Ed25519ctx(); return(true); case "ED25519PH": algorithm = new Ed25519ph(); return(true); case "ED448": algorithm = new Ed448(); return(true); case "ED448PH": algorithm = new Ed448ph(); return(true); case "GOST3411WITHECGOST3410": case "ECGOST3410": case "ECGOST3410-2001": case "ECGOST-3410": case "ECGOST-3410-2001": algorithm = GOST3411withECGOST3410; return(true); case "GOST3411WITHGOST3410": case "GOST3410": case "GOST3410-94": case "GOST-3410": case "GOST-3410-94": algorithm = GOST3411withGOST3410; return(true); case "RIPEMD160WITHPLAIN-ECDSA": case "RIPEMD-160WITHPLAIN-ECDSA": algorithm = RIPEMD160withPLAIN_ECDSA; return(true); case "SHA1WITHPLAIN-ECDSA": case "SHA-1WITHPLAIN-ECDSA": algorithm = SHA1withPLAIN_ECDSA; return(true); case "SHA224WITHPLAIN-ECDSA": case "SHA-224WITHPLAIN-ECDSA": algorithm = SHA224withPLAIN_ECDSA; return(true); case "SHA256WITHPLAIN-ECDSA": case "SHA-256WITHPLAIN-ECDSA": algorithm = SHA256withPLAIN_ECDSA; return(true); case "SHA384WITHPLAIN-ECDSA": case "SHA-384WITHPLAIN-ECDSA": algorithm = SHA384withPLAIN_ECDSA; return(true); case "SHA512WITHPLAIN-ECDSA": case "SHA-512WITHPLAIN-ECDSA": algorithm = SHA512withPLAIN_ECDSA; return(true); case "PSSWITHRSA": algorithm = PSSwithRSA; return(true); case "SHA1WITHDSA": case "SHA-1WITHDSA": algorithm = SHA1withDSA; return(true); case "SHA224WITHDSA": case "SHA-224WITHDSA": algorithm = SHA224withDSA; return(true); case "SHA256WITHDSA": case "SHA-256WITHDSA": algorithm = SHA256withDSA; return(true); case "SHA384WITHDSA": case "SHA-384WITHDSA": algorithm = SHA384withDSA; return(true); case "SHA512WITHDSA": case "SHA-512WITHDSA": algorithm = SHA512withDSA; return(true); case "SHA3-224WITHDSA": case "SHA-3-224WITHDSA": algorithm = SHA3_224withDSA; return(true); case "SHA3-256WITHDSA": case "SHA-3-256WITHDSA": algorithm = SHA3_256withDSA; return(true); case "SHA3-384WITHDSA": case "SHA-3-384WITHDSA": algorithm = SHA3_384withDSA; return(true); case "SHA3-512WITHDSA": case "SHA-3-512WITHDSA": algorithm = SHA3_512withDSA; return(true); case "SHA1WITHECDSA": case "SHA-1WITHECDSA": algorithm = SHA1withECDSA; return(true); case "SHA224WITHECDSA": case "SHA-224WITHECDSA": algorithm = SHA224withECDSA; return(true); case "SHA256WITHECDSA": case "SHA-256WITHECDSA": algorithm = SHA256withECDSA; return(true); case "SHA384WITHECDSA": case "SHA-384WITHECDSA": algorithm = SHA384withECDSA; return(true); case "SHA512WITHECDSA": case "SHA-512WITHECDSA": algorithm = SHA512withECDSA; return(true); case "SHA3-224WITHECDSA": case "SHA-3-224WITHECDSA": algorithm = SHA3_224withECDSA; return(true); case "SHA3-256WITHECDSA": case "SHA-3-256WITHECDSA": algorithm = SHA3_256withECDSA; return(true); case "SHA3-384WITHECDSA": case "SHA-3-384WITHECDSA": algorithm = SHA3_384withECDSA; return(true); case "SHA3-512WITHECDSA": case "SHA-3-512WITHECDSA": algorithm = SHA3_512withECDSA; return(true); case "MD2WITHRSA": algorithm = MD2withRSA; return(true); case "MD5WITHRSA": algorithm = MD5withRSA; return(true); case "RIPEMD128WITHRSA": case "RIPEMD-128WITHRSA": algorithm = RIPEMD128withRSA; return(true); case "RIPEMD160WITHRSA": case "RIPEMD-160WITHRSA": algorithm = RIPEMD160withRSA; return(true); case "RIPEMD256WITHRSA": case "RIPEMD-256WITHRSA": algorithm = RIPEMD256withRSA; return(true); case "SHA1WITHRSA": case "SHA-1WITHRSA": algorithm = SHA1withRSA; return(true); case "SHA224WITHRSA": case "SHA-224WITHRSA": algorithm = SHA224withRSA; return(true); case "SHA256WITHRSA": case "SHA-256WITHRSA": algorithm = SHA256withRSA; return(true); case "SHA384WITHRSA": case "SHA-384WITHRSA": algorithm = SHA384withRSA; return(true); case "SHA512WITHRSA": case "SHA-512WITHRSA": algorithm = SHA512withRSA; return(true); case "SHA3-224WITHRSA": case "SHA-3-224WITHRSA": algorithm = SHA3_224withRSA; return(true); case "SHA3-256WITHRSA": case "SHA-3-256WITHRSA": algorithm = SHA3_256withRSA; return(true); case "SHA3-384WITHRSA": case "SHA-3-384WITHRSA": algorithm = SHA3_384withRSA; return(true); case "SHA3-512WITHRSA": case "SHA-3-512WITHRSA": algorithm = SHA3_512withRSA; return(true); case "SHA1WITHRSAANDMGF1": case "SHA-1WITHRSAANDMGF1": algorithm = PSSwithRSA; return(true); case "SHA256WITHSM2": case "SHA-256WITHSM2": algorithm = SHA256withSM2; return(true); case "SM3WITHSM2": algorithm = SM3withSM2; return(true); default: break; } string prefix; string suffix; int index = mechanism.IndexOf("WITH"); if (index >= 0) { prefix = mechanism.Substring(0, index); suffix = mechanism.Substring(index + 4, mechanism.Length - index - 4); } else { prefix = string.Empty; suffix = mechanism; } if (suffix == "ELGAMAL") { algorithm = null; return(false); } if (HashAlgorithmHelper.TryGetAlgorithm(prefix, out IHashAlgorithm hashAlgorithm)) { switch (suffix) { case "CVC-ECDSA": algorithm = new CVC_ECDSA(hashAlgorithm); return(true); case "DSA": algorithm = new DSA(hashAlgorithm); return(true); case "ECDSA": algorithm = new ECDSA(hashAlgorithm); return(true); case "ECGOST3410": case "ECGOST3410-2001": case "ECGOST-3410": case "ECGOST-3410-2001": algorithm = new ECGOST3410(hashAlgorithm); return(true); case "ECNR": algorithm = new ECNR(hashAlgorithm); return(true); case "GOST3410": case "GOST3410-94": case "GOST-3410": case "GOST-3410-94": algorithm = new GOST3410(hashAlgorithm); return(true); case "PLAIN-ECDSA": algorithm = new PLAIN_ECDSA(hashAlgorithm); return(true); case "RSA": algorithm = new RSA(hashAlgorithm); return(true); case "ISO9796-2": case "RSA/ISO9796-2": case "RSAANDISO9796-2": algorithm = new RSAandISO9796_2(hashAlgorithm); return(true); case "RSAANDMGF1": algorithm = new RSAandMGF1(hashAlgorithm); return(true); case "RSA/X9.31": case "RSA/X931": case "RSAANDX931": case "RSAANDX9.31": algorithm = new RSAandX931(hashAlgorithm); return(true); case "SM2": algorithm = new SM2(hashAlgorithm); return(true); default: break; } } algorithm = null; return(false); }
public static void Precompute() { Ed448.Precompute(); }
public Ed448PublicKeyParameters GeneratePublicKey() { byte[] publicKey = new byte[Ed448.PublicKeySize]; Ed448.GeneratePublicKey(data, 0, publicKey, 0); return(new Ed448PublicKeyParameters(publicKey, 0)); }