public void CertificateSignedByTrustedSignerWhileSignerCertificateHashExistsTwice_ShouldThrow_TrustException() { // Arrange var certificate = RsaKey.Generate().DeriveCertificate(); var signedCertificate = ScenarioRsa.DefaultSignerKey.Sign((RsaCertificate)certificate); var signerCertificateParameters = ScenarioRsa.DefaultSignerCertificate.CreateRsa().ExportParameters(false); var signerCertificateDuplicate = new RsaCertificate( parameters: signerCertificateParameters, embeddedData: ScenarioRsa.DefaultSignerCertificate.EmbeddedData); var chainOfTrust = new ChainOfTrust( ScenarioRsa.DefaultSignerCertificate, signerCertificateDuplicate); // Act & Assert Assert.Throws <TrustException>(() => chainOfTrust.Verify(signedCertificate)); }
static ScenarioRsa() { DefaultData = new byte[] { 0x00, 0x01, 0x02, 0x03 }; DefaultDataHash = Sha512Hash.Compute(DefaultData); DefaultEmbeddedData = new byte[] { 0xff, 0xee, 0xdd, 0xcc }; DefaultKey = RsaKey.Generate(); DefaultRsa = DefaultKey.CreateRsa(); DefaultRsaParameters = DefaultRsa.ExportParameters(true); DefaultCertificateSignature = new RsaSignature(Sha512Hash.Compute(new byte[] { 0x12, 0x34, 0xaa, 0xbb }), new byte[] { 0xa1, 0xb2, 0xc3, 0xd4 }); DefaultCertificate = new RsaCertificate(DefaultRsaParameters, DefaultCertificateSignature); DefaultSignerKey = RsaKey.Generate(); DefaultSignerCertificate = (RsaCertificate)DefaultSignerKey.DeriveCertificate(); DefaultSignatureData = new byte[] { 0x1f, 0x2f, 0x3f, 0x4f }; DefaultSignature = new RsaSignature(DefaultSignerCertificate.Hash, DefaultSignatureData); DefaultChain = new ChainOfTrust(DefaultSignerCertificate); }
public Scenario3() { this.CertificateLocator = Mock.Of <ICertificateLocator>(); this.ChainWithLocator = new ChainOfTrust(this.CertificateLocator, ScenarioRsa.DefaultSignerCertificate); }
public void TrustedCertificatesEmpty_Should_Succeed() { // Arrange // Act & Assert var sut = new ChainOfTrust(trustedCertificates: new ICertificate[0]); }