示例#1
0
 public void GetAndTestIdFile()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Integrity integrityTest = new Integrity();
     byte[] idFile = dataTest.GetIdFile();
     byte[] idSignatureFile = dataTest.GetIdSignatureFile();
     byte[] certificateRRN = null;
        // Assert.False(integrityTest.Verify(idFile, idSignatureFile, certificateRRN));
 }
示例#2
0
 public void IntegrityIdentityFileWrongCertificate()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Integrity integrityTest = new Integrity();
     byte[] idFile = dataTest.GetIdFile();
     byte[] idSignatureFile = dataTest.GetIdSignatureFile();
     byte[] certificateRoot = dataTest.GetCertificateRootFile();
     Assert.False(integrityTest.Verify(idFile, idSignatureFile, certificateRoot));
 }
示例#3
0
 public void GetCertificateRNFile()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     byte[] certificateRNFile = dataTest.GetCertificateRNFile();
     X509Certificate certificateRN;
     Assert.DoesNotThrow(delegate { certificateRN = new X509Certificate(certificateRNFile); });
     certificateRN = new X509Certificate(certificateRNFile);
     Assert.True(certificateRN.Issuer.Contains("Root"));
 }
示例#4
0
        public void GetAndTestIdFile()
        {
            ReadData  dataTest      = new ReadData("beidpkcs11.dll");
            Integrity integrityTest = new Integrity();

            byte[] idFile          = dataTest.GetIdFile();
            byte[] idSignatureFile = dataTest.GetIdSignatureFile();
            //byte[] certificateRRN = null;
            //Assert.isFalse(integrityTest.Verify(idFile, idSignatureFile, certificateRRN));
        }
 public void ValidityAuthenticationChain()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Integrity integrityTest = new Integrity();
     List<byte[]> caCerts = new List <byte[]>();
     caCerts.Add(dataTest.GetCertificateCAFile());
     Assert.True(integrityTest.CheckCertificateChain(
         caCerts,
         dataTest.GetCertificateAuthenticationFile()));
 }
示例#6
0
 public void GetCertificateRootFile()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     byte[] certificateFile = dataTest.GetCertificateRootFile();
     X509Certificate certificateRoot;
     Assert.DoesNotThrow(delegate { certificateRoot = new X509Certificate(certificateFile); });
     certificateRoot = new X509Certificate(certificateFile);
     Assert.AreEqual(certificateRoot.Subject, certificateRoot.Issuer, "Should be a self-signed root certificate");
     Assert.True(certificateRoot.Subject.Contains("Root"));
 }
示例#7
0
 public void IntegrityAddressFile()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Integrity integrityTest = new Integrity();
     byte[] addressFile = trimRight(dataTest.GetAddressFile());
     byte[] idSignatureFile = dataTest.GetIdSignatureFile();
     byte[] concatFiles = new byte[addressFile.Length + idSignatureFile.Length];
     Array.Copy(addressFile, 0, concatFiles, 0, addressFile.Length);
     Array.Copy(idSignatureFile, 0, concatFiles, addressFile.Length, idSignatureFile.Length);
     byte[] addressSignatureFile = dataTest.GetAddressSignatureFile();
     byte[] certificateRRN = dataTest.GetCertificateRNFile();
     Assert.True(integrityTest.Verify(concatFiles, addressSignatureFile, certificateRRN));
 }
示例#8
0
 public void SignSignature()
 {
     // Sign
     Sign signTest = new Sign("beidpkcs11.dll");
     byte[] testdata = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
     byte[] signeddata = signTest.DoSign(testdata, "Signature");
     Assert.IsNotNull(signeddata);
     // Verification
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Integrity integrityTest = new Integrity();
     Assert.False(integrityTest.Verify(testdata, signeddata,
         dataTest.GetCertificateAuthenticationFile()));
     Assert.True(integrityTest.Verify(testdata, signeddata,
         dataTest.GetCertificateSignatureFile()));
 }
示例#9
0
        public void GetIdFile()
        {
            ReadData dataTest = new ReadData("beidpkcs11.dll");
            byte [] idFile = dataTest.GetIdFile();
            int i = 0;

            // poor man's tlv parser...
            // we'll check the first two tag fields (01 and 02)
            Assert.AreEqual(0x01, idFile[i++]); // Tag
            i += idFile[i];                     // Length - skip value
            i++;
            Assert.AreEqual(0x02, idFile[i]); // Tag
        }
示例#10
0
 public void GetDateOfBirth()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Assert.AreEqual("01 JAN 1971", dataTest.GetDateOfBirth());
 }
示例#11
0
 public void GetChipnumber()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     dataTest.GetChipnumber();
     //Assert.AreEqual("SPECIMEN", dataTest.GetSurname());
 }
示例#12
0
 public void GetCertificateLabels()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     List<string> labels = dataTest.GetCertificateLabels();
     //Assert.True(labels.Contains("Authentication"),"Find Authentication certificate");
 }
示例#13
0
        public void StoreCertificateRNFile()
        {
            ReadData dataTest = new ReadData("beidpkcs11.dll");
            byte[] certificateRNFile = dataTest.GetCertificateRNFile();
            X509Certificate2 certificateRN = new X509Certificate2(certificateRNFile);

            X509Store mystore = new X509Store(StoreName.My);
            mystore.Open(OpenFlags.ReadWrite);
            mystore.Add(certificateRN);
        }
示例#14
0
 public void GetTokenInfoLabel()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Assert.AreEqual("BELPIC", dataTest.GetTokenInfoLabel().Trim());
 }
示例#15
0
 public void GetSlotDescription()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     Assert.AreEqual("ACS CCID USB Reader 0", dataTest.GetSlotDescription());
 }
示例#16
0
 public void GetPhotoFile()
 {
     ReadData dataTest = new ReadData("beidpkcs11.dll");
     byte[] photoFile = dataTest.GetPhotoFile();
     Bitmap photo = new Bitmap(new MemoryStream(photoFile));
     Assert.AreEqual(140, photo.Width);
     Assert.AreEqual(200, photo.Height);
 }