public void TestHsmCrypto_Unsuported_methods() { using (var hsmCryptographer = new HsmCryptographer()) { hsmCryptographer.Init(TokenSettings); var agentB = AgentTester.CreateAgent( "hsm.DirectInt.lab", AgentTester.MakeCertificatesPath(Directory.GetCurrentDirectory(), "nhind"), hsmCryptographer); var tester = new AgentTester(new DirectAgent(AgentTester.DefaultDomainA), agentB); string messageText = tester.ReadMessageText("simpleHsmToSoft.eml"); var message = MimeSerializer.Default.Deserialize <Message>(messageText); Assert.Throws <NotImplementedException>(() => tester.AgentB.Cryptographer .Encrypt( message, m_singleUseEnciphermentPublicCert)); Assert.Throws <NotImplementedException>(() => tester.AgentB.Cryptographer .Encrypt( message, new X509Certificate2Collection(m_singleUseEnciphermentPublicCert))); } }
public void TestHsmCrypto_Unsupported_methods2() { // Hardware Cryptographer Agent using (var hsmCryptographer = new HsmCryptographer()) { var diagnostics = new FakeDiagnostics(typeof(HsmCryptographerProxy)); hsmCryptographer.Error += diagnostics.OnResolverError; hsmCryptographer.Init(TokenSettings); var agentB = AgentTester.CreateAgent( "hsm.DirectInt.lab", AgentTester.MakeCertificatesPath(Directory.GetCurrentDirectory(), "nhind"), hsmCryptographer); // Software Cryptographer Agent var agentA = AgentTester.CreateAgent( AgentTester.DefaultDomainA, AgentTester.MakeCertificatesPath(Directory.GetCurrentDirectory(), "redmond"), //new TestSmimeCryptographer(EncryptionAlgorithm.AES128, DigestAlgorithm.SHA256)); SMIMECryptographer.Default); var tester = new AgentTester(agentA, agentB); string messageText = tester.ReadMessageText("simpleSoftToHsm.eml"); var message = MimeSerializer.Default.Deserialize <Message>(messageText); var signedEntity = tester.AgentB.Cryptographer.Sign(message, m_singleUseSigningPublicCert); // // SignedEntity has Content and Signature in MimeEntity formats. // Console.WriteLine("*** Content Entity:\r\n" + signedEntity.Content); Console.WriteLine("*** Signature Entity:\r\n" + signedEntity.Signature); Assert.Throws <NotImplementedException>(() => tester.AgentB.Cryptographer.DeserializeDetachedSignature(signedEntity)); Assert.Throws <NotImplementedException>(() => tester.AgentB.Cryptographer.DeserializeEnvelopedSignature(signedEntity.ToEntity())); } }