Example #1
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();
		}
        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 #3
0
 protected virtual ISigner MakeSigner(IDigest d, bool forSigning, ICipherParameters cp)
 {
     ISigner s = new GenericSigner(CreateRsaImpl(), d);
     s.Init(forSigning, cp);
     return s;
 }
 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 #5
0
 public virtual ISigner CreateVerifyer(AsymmetricKeyParameter publicKey)
 {
     ISigner s = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), new CombinedHash());
     s.Init(false, publicKey);
     return s;
 }