示例#1
0
 public Certificate(CertificateRequest request, CertificateIssuer issuer)
 {
     _subject = request.Dn;
     _subjectPublicKey = request.PublicKey;
     _issuer = issuer.DistinguishedName;
     _cert = Create(request, issuer.Key.PrivateAsymmetricKey);
 }
示例#2
0
文件: Key.cs 项目: bitdiff/secular
        public Key(int strength)
        {
            var generator = new RsaKeyPairGenerator();
            generator.Init(new KeyGenerationParameters(new SecureRandom(), strength));
            _keyPair = generator.GenerateKeyPair();
            _rsaKey = _keyPair.Private as RsaPrivateCrtKeyParameters;

            PublicKey = new PublicKey(_keyPair.Public as RsaKeyParameters);
        }
示例#3
0
文件: Key.cs 项目: bitdiff/secular
        public Key(string pem)
        {
            var k = new CertificateLoader().LoadFirst<AsymmetricCipherKeyPair>("key", pem);
            _rsaKey = k.Private as RsaPrivateCrtKeyParameters;

            if (_rsaKey == null)
                throw new SecularException("Cannot find key in PEM string.");

            var rsaKeyParameters = new RsaKeyParameters(false, _rsaKey.Modulus, _rsaKey.PublicExponent);
            PublicKey = new PublicKey(rsaKeyParameters);
        }
示例#4
0
        public Certificate(Action<CertificateRequest> r, Action<CertificateIssuer> i)
        {
            var request = new CertificateRequest();
            var issuer = new CertificateIssuer();
            r(request);
            i(issuer);

            _subject = request.Dn;
            _subjectPublicKey = request.PublicKey;
            _issuer = issuer.DistinguishedName;
            _cert = Create(request, issuer.Key.PrivateAsymmetricKey);
        }