public Certificate(CertificateRequest request, CertificateIssuer issuer) { _subject = request.Dn; _subjectPublicKey = request.PublicKey; _issuer = issuer.DistinguishedName; _cert = Create(request, issuer.Key.PrivateAsymmetricKey); }
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); }
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); }
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); }