public void Test() {
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
byte[] blob = rsa.ExportCspBlob(false);
RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
rsa_pub.ImportCspBlob(blob);
CertificateMaker cm = new CertificateMaker("United States", "UFL",
"ACIS", "David Wolinsky", "[email protected]", rsa_pub,
"brunet:node:abcdefghijklmnopqrs");
Assert.AreEqual("C=United States, O=UFL, OU=ACIS, CN=David Wolinsky, [email protected]", cm.Subject.DN, "DN test 1");
cm = new CertificateMaker(cm.UnsignedData);
Assert.AreEqual("C=United States, O=UFL, OU=ACIS, CN=David Wolinsky, [email protected]", cm.Subject.DN, "DN test 2");
Certificate cert = cm.Sign(cm, rsa);
Assert.IsTrue(cert.Signature != null, "Signature");
Assert.AreEqual(cm.Subject.DN, cert.Issuer.DN, "Issuer = Subject");
Assert.AreEqual("brunet:node:abcdefghijklmnopqrs", cert.NodeAddress , "Node address");
Mono.Math.BigInteger rsa_pub_bi = new Mono.Math.BigInteger(rsa_pub.ExportCspBlob(false));
Mono.Math.BigInteger cert_pub_bi = new Mono.Math.BigInteger(cert.PublicKey.ExportCspBlob(false));
Assert.AreEqual(rsa_pub_bi, cert_pub_bi, "Key");
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
Assert.AreEqual(MemBlock.Reference(cert.SerialNumber),
MemBlock.Reference(sha1.ComputeHash(cert.UnsignedData)),
"SerialNumber == hash of unsigned data");
}
}