Exemplo n.º 1
0
            internal byte[] GenerateSignature(Ed448PrivateKeyParameters privateKey, Ed448PublicKeyParameters publicKey, byte[] ctx)
            {
#if PORTABLE
                byte[] buf   = ToArray();
                int    count = buf.Length;
#else
                byte[] buf   = GetBuffer();
                int    count = (int)Position;
#endif
                byte[] signature = new byte[Ed448PrivateKeyParameters.SignatureSize];
                privateKey.Sign(Ed448.Algorithm.Ed448, publicKey, ctx, buf, 0, count, signature, 0);
                Reset();
                return(signature);
            }
        public virtual byte[] GenerateSignature()
        {
            if (!forSigning || null == privateKey)
            {
                throw new InvalidOperationException("Ed448phSigner not initialised for signature generation.");
            }

            byte[] msg = new byte[Ed448.PrehashSize];
            if (Ed448.PrehashSize != prehash.DoFinal(msg, 0, Ed448.PrehashSize))
            {
                throw new InvalidOperationException("Prehash digest failed");
            }

            byte[] signature = new byte[Ed448PrivateKeyParameters.SignatureSize];
            privateKey.Sign(Ed448.Algorithm.Ed448ph, publicKey, context, msg, 0, Ed448.PrehashSize, signature, 0);
            return(signature);
        }