protected virtual ISigner MakeSigner(IDigest d, bool forSigning, ICipherParameters cp)
        {
            ISigner s = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), d);

            s.Init(forSigning, cp);
            return(s);
        }
Example #2
0
        public virtual ISigner CreateVerifyer(AsymmetricKeyParameter publicKey)
        {
            ISigner s = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), new CombinedHash());

            s.Init(false, publicKey);
            return(s);
        }
Example #3
0
        protected virtual ISigner MakeSigner(IDigest d, bool forSigning, ICipherParameters cp)
        {
            ISigner s = new GenericSigner(CreateRsaImpl(), d);

            s.Init(forSigning, cp);
            return(s);
        }
Example #4
0
        public byte[] CalculateRawSignature(AsymmetricKeyParameter privateKey, byte[] md5andsha1)
        {
            ISigner sig = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), new NullDigest());

            sig.Init(true, privateKey);
            sig.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
            return(sig.GenerateSignature());
        }
Example #5
0
        protected virtual ISigner MakeSigner(SignatureAndHashAlgorithm algorithm, bool raw, bool forSigning,
                                             ICipherParameters cp)
        {
            if ((algorithm != null) != TlsUtilities.IsTlsV12(mContext))
            {
                throw new InvalidOperationException();
            }
            if (algorithm != null && algorithm.Signature != SignatureAlgorithm.rsa)
            {
                throw new InvalidOperationException();
            }

            IDigest d;

            if (raw)
            {
                d = new NullDigest();
            }
            else if (algorithm == null)
            {
                d = new CombinedHash();
            }
            else
            {
                d = TlsUtilities.CreateHash(algorithm.Hash);
            }

            ISigner s;

            if (algorithm != null)
            {
                /*
                 * RFC 5246 4.7. In RSA signing, the opaque vector contains the signature generated
                 * using the RSASSA-PKCS1-v1_5 signature scheme defined in [PKCS1].
                 */
                s = new RsaDigestSigner(d, TlsUtilities.GetOidForHashAlgorithm(algorithm.Hash));
            }
            else
            {
                /*
                 * RFC 5246 4.7. Note that earlier versions of TLS used a different RSA signature scheme
                 * that did not include a DigestInfo encoding.
                 */
                s = new GenericSigner(CreateRsaImpl(), d);
            }
            s.Init(forSigning, cp);
            return(s);
        }
Example #6
0
        protected virtual ISigner MakeSigner(SignatureAndHashAlgorithm algorithm, bool raw, bool forSigning, ICipherParameters cp)
        {
            if (algorithm != null != TlsUtilities.IsTlsV12(this.mContext))
            {
                throw new InvalidOperationException();
            }
            if (algorithm != null && algorithm.Signature != 1)
            {
                throw new InvalidOperationException();
            }
            IDigest digest;

            if (raw)
            {
                digest = new NullDigest();
            }
            else if (algorithm == null)
            {
                digest = new CombinedHash();
            }
            else
            {
                digest = TlsUtilities.CreateHash(algorithm.Hash);
            }
            ISigner signer;

            if (algorithm != null)
            {
                signer = new RsaDigestSigner(digest, TlsUtilities.GetOidForHashAlgorithm(algorithm.Hash));
            }
            else
            {
                signer = new GenericSigner(this.CreateRsaImpl(), digest);
            }
            signer.Init(forSigning, cp);
            return(signer);
        }