Exemple #1
0
        public void GenerateSignature()
        {
            var certificate = new IssuerPublicKeyCertificate
            {
                HashAlgorithmIndicator      = 0x01,
                IssuerIdentifier            = "49000000".FromHexa(),
                CertificateExpirationDate   = "0714".FromHexa(),
                CertificateSerialNumber     = "000001".FromHexa(),
                PublicKeyAlgorithmIndicator = 1,
                IssuerPublicKey             = new PublicKey(IssuerModulus, IssuerPublicExponent)
            };

            var bytes = certificate.GenerateCertificate(new PublicKey(AcModulus, AcPrivateExponent));

            Assert.AreEqual(IssuerPublicKeyCertificateBytes, bytes.ToHexa('\0'));
        }
Exemple #2
0
        public void RecoverFromSignature()
        {
            var certificate = new IssuerPublicKeyCertificate();

            certificate.RecoverFromSignature(IssuerPublicKeyCertificateBytes.FromHexa(), new PublicKey(AcModulus, AcPublicExponent));

            Assert.AreEqual(0x6A, certificate.DataHeader);
            Assert.AreEqual(0xBC, certificate.DataTrailer);
            Assert.AreEqual(0x02, certificate.DataFormat);
            Assert.AreEqual(0x01, certificate.HashAlgorithmIndicator);
            Assert.AreEqual(Hash, certificate.HashResult.ToHexa('\0'));
            Assert.AreEqual(Recovered, certificate.Recovered.ToHexa('\0'));

            Assert.AreEqual(0x01, certificate.PublicKeyAlgorithmIndicator);
            Assert.AreEqual(0x03, certificate.PublicKeyExponentLength);
            Assert.AreEqual(0x80, certificate.PublicKeyLength);
            Assert.AreEqual("49000000".FromHexa(), certificate.IssuerIdentifier);
            Assert.AreEqual(LeftmostDigitsofthePublicKey, certificate.PublicKeyorLeftmostDigitsofthePublicKey.ToHexa('\0'));
        }