/// <summary>
        /// Create PKCS 10 from hex string.
        /// </summary>
        /// <param name="data">Hex string.</param>
        /// <returns>PKCS 10</returns>
        public static GXPkcs10 FromHexString(string data)
        {
            GXPkcs10 cert = new GXPkcs10();

            cert.Init(GXCommon.HexToBytes(data));
            return(cert);
        }
Beispiel #2
0
        /// <summary>
        /// Create x509Certificate from DER Base64 encoded string.
        /// </summary>
        /// <param name="der">Base64 DER string.</param>
        /// <returns></returns>
        public static GXPkcs10 FromDer(string der)
        {
            der = der.Replace("\r\n", "");
            der = der.Replace("\n", "");
            GXPkcs10 cert = new GXPkcs10();

            cert.Init(GXCommon.FromBase64(der));
            return(cert);
        }
Beispiel #3
0
        /// <summary>
        /// Create Certificate Signing Request.
        /// </summary>
        /// <param name="kp">KeyPair </param>
        /// <param name="subject">Subject.</param>
        /// <returns> Created GXPkcs10.</returns>
        public static GXPkcs10 CreateCertificateSigningRequest(KeyValuePair <GXPrivateKey, GXPublicKey> kp, string subject)
        {
            GXPkcs10 pkc10 = new GXPkcs10();

            pkc10.Algorithm = X9ObjectIdentifier.IdECPublicKey;
            pkc10.PublicKey = kp.Value;
            pkc10.Subject   = subject;
            pkc10.Sign(kp.Key, kp.Key.Scheme == Ecdsa.Enums.Ecc.P256 ? HashAlgorithm.Sha256WithEcdsa : HashAlgorithm.Sha384WithEcdsa);
            return(pkc10);
        }
Beispiel #4
0
        /// <summary>
        /// Create Certificate Signing Request.
        /// </summary>
        /// <param name="kp">KeyPair </param>
        /// <param name="subject">Subject.</param>
        /// <returns> Created GXPkcs10.</returns>
        public static GXPkcs10 CreateCertificateSigningRequest(KeyValuePair <GXPrivateKey, GXPublicKey> kp, string subject)
        {
            GXPkcs10 pkc10 = new GXPkcs10();

            pkc10.Algorithm = X9ObjectIdentifier.IdECPublicKey;
            pkc10.PublicKey = kp.Value;
            pkc10.Subject   = subject;
            pkc10.Sign(kp.Key, HashAlgorithm.Sha256withecdsa);
            return(pkc10);
        }
Beispiel #5
0
 /// <summary>
 /// Load Pkcs10 Certificate Signing Request from the PEM (.csr) file.
 /// </summary>
 /// <param name="path">File path.</param>
 /// <returns>Created GXPkcs10 object. </returns>
 ///
 public static GXPkcs10 Load(string path)
 {
     return(GXPkcs10.FromPem(File.ReadAllText(path)));
 }