Add tests for parsing CSRs
This commit is contained in:
parent
5eeb32b552
commit
d4fd57dda4
7 changed files with 111 additions and 0 deletions
8
tests/data_files/server5.req.sha1
Normal file
8
tests/data_files/server5.req.sha1
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIBGDCBvwIBADA0MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxEjAQ
|
||||||
|
BgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDfMVtl2
|
||||||
|
CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA2CMR/+ov0jRdXRa9iojCa3cN
|
||||||
|
Vc2KKg76Aci07f+gKTAnBgkqhkiG9w0BCQ4xGjAYMAkGA1UdEwQCMAAwCwYDVR0P
|
||||||
|
BAQDAgXgMAkGByqGSM49BAEDSQAwRgIhALSf2Mj3er+ocZCN++aEoIp5PQ9JCkPY
|
||||||
|
b88ghuTyS7DCAiEA+CnVzNN0I2kpnmKUOUcXxLcjoPaLROgxtubDvKv5ckM=
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
8
tests/data_files/server5.req.sha224
Normal file
8
tests/data_files/server5.req.sha224
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIBGDCBvwIBADA0MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxEjAQ
|
||||||
|
BgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDfMVtl2
|
||||||
|
CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA2CMR/+ov0jRdXRa9iojCa3cN
|
||||||
|
Vc2KKg76Aci07f+gKTAnBgkqhkiG9w0BCQ4xGjAYMAkGA1UdEwQCMAAwCwYDVR0P
|
||||||
|
BAQDAgXgMAoGCCqGSM49BAMBA0gAMEUCIDYaN1m9MRk5mhX1U8aZKd0alyGKWqcR
|
||||||
|
oglF2MsIii/2AiEAjFHs8XQ0Q4yDF8oLztCxlq3nAvqmPdQz9T+TkEfh+PA=
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
8
tests/data_files/server5.req.sha256
Normal file
8
tests/data_files/server5.req.sha256
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIBFzCBvwIBADA0MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxEjAQ
|
||||||
|
BgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDfMVtl2
|
||||||
|
CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA2CMR/+ov0jRdXRa9iojCa3cN
|
||||||
|
Vc2KKg76Aci07f+gKTAnBgkqhkiG9w0BCQ4xGjAYMAkGA1UdEwQCMAAwCwYDVR0P
|
||||||
|
BAQDAgXgMAoGCCqGSM49BAMCA0cAMEQCIGmRFdjjd53oM2Zpt3E5vfqujnA+DHWk
|
||||||
|
s9OudcSWBdjmAiA7BAYjGnXyL6ATPqM7qnLVGTf3JMT+1rXl7esBm/0APA==
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
8
tests/data_files/server5.req.sha384
Normal file
8
tests/data_files/server5.req.sha384
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIBFzCBvwIBADA0MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxEjAQ
|
||||||
|
BgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDfMVtl2
|
||||||
|
CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA2CMR/+ov0jRdXRa9iojCa3cN
|
||||||
|
Vc2KKg76Aci07f+gKTAnBgkqhkiG9w0BCQ4xGjAYMAkGA1UdEwQCMAAwCwYDVR0P
|
||||||
|
BAQDAgXgMAoGCCqGSM49BAMDA0cAMEQCIDnO+PIPZJGqiky9unvq13uXxahw1bpk
|
||||||
|
Zb5NRV0c06Q5AiAo5B49tp3kDN/n0BDNt1BBGLUfhcU+Qn2SQenCyfuGLg==
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
8
tests/data_files/server5.req.sha512
Normal file
8
tests/data_files/server5.req.sha512
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIBGDCBvwIBADA0MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxEjAQ
|
||||||
|
BgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDfMVtl2
|
||||||
|
CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA2CMR/+ov0jRdXRa9iojCa3cN
|
||||||
|
Vc2KKg76Aci07f+gKTAnBgkqhkiG9w0BCQ4xGjAYMAkGA1UdEwQCMAAwCwYDVR0P
|
||||||
|
BAQDAgXgMAoGCCqGSM49BAMEA0gAMEUCIQD8xdtluTiBJM50d/WvDeUvPbXOUMlL
|
||||||
|
8xEJXU2WOK+RLAIgS8U6Z8tlJpXLEisz/j4gdABG3Y3h4PBJjlpszFisTNo=
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
|
@ -170,6 +170,54 @@ X509 CRL Information EC, SHA512 Digest
|
||||||
depends_on:POLARSSL_PEM_PARSE_C
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
x509_crl_info:"data_files/crl-ec-sha512.pem":"CRL version \: 2\nissuer name \: C=NL, O=PolarSSL, CN=Polarssl Test EC CA\nthis update \: 2013-09-24 16\:31\:08\nnext update \: 2023-09-22 16\:31\:08\nRevoked certificates\:\nserial number\: 0A revocation date\: 2013-09-24 16\:28\:38\nsigned using \: ECDSA with SHA512\n"
|
x509_crl_info:"data_files/crl-ec-sha512.pem":"CRL version \: 2\nissuer name \: C=NL, O=PolarSSL, CN=Polarssl Test EC CA\nthis update \: 2013-09-24 16\:31\:08\nnext update \: 2023-09-22 16\:31\:08\nRevoked certificates\:\nserial number\: 0A revocation date\: 2013-09-24 16\:28\:38\nsigned using \: ECDSA with SHA512\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with MD4
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.md4":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with MD4\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with MD5
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.md5":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with MD5\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with SHA1
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.sha1":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with SHA224
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.sha224":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-224\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with SHA256
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.sha256":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-256\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with SHA384
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.sha384":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-384\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information RSA with SHA512
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server1.req.sha512":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-512\nRSA key size \: 2048 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information EC with SHA1
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server5.req.sha1":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA1\nEC key size \: 256 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information EC with SHA224
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server5.req.sha224":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA224\nEC key size \: 256 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information EC with SHA256
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server5.req.sha256":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA256\nEC key size \: 256 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information EC with SHA384
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server5.req.sha384":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA384\nEC key size \: 256 bits\n"
|
||||||
|
|
||||||
|
X509 CSR Information EC with SHA512
|
||||||
|
depends_on:POLARSSL_PEM_PARSE_C
|
||||||
|
x509_csr_info:"data_files/server5.req.sha512":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA512\nEC key size \: 256 bits\n"
|
||||||
|
|
||||||
X509 Get Distinguished Name #1
|
X509 Get Distinguished Name #1
|
||||||
depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C
|
depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C
|
||||||
x509_dn_gets:"data_files/server1.crt":"subject":"C=NL, O=PolarSSL, CN=PolarSSL Server 1"
|
x509_dn_gets:"data_files/server1.crt":"subject":"C=NL, O=PolarSSL, CN=PolarSSL Server 1"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* BEGIN_HEADER */
|
/* BEGIN_HEADER */
|
||||||
#include <polarssl/x509_crt.h>
|
#include <polarssl/x509_crt.h>
|
||||||
#include <polarssl/x509_crl.h>
|
#include <polarssl/x509_crl.h>
|
||||||
|
#include <polarssl/x509_csr.h>
|
||||||
#include <polarssl/pem.h>
|
#include <polarssl/pem.h>
|
||||||
#include <polarssl/oid.h>
|
#include <polarssl/oid.h>
|
||||||
|
|
||||||
|
@ -75,6 +76,28 @@ void x509_crl_info( char *crl_file, char *result_str )
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CSR_PARSE_C */
|
||||||
|
void x509_csr_info( char *csr_file, char *result_str )
|
||||||
|
{
|
||||||
|
x509_csr csr;
|
||||||
|
char buf[2000];
|
||||||
|
int res;
|
||||||
|
|
||||||
|
x509_csr_init( &csr );
|
||||||
|
memset( buf, 0, 2000 );
|
||||||
|
|
||||||
|
TEST_ASSERT( x509_csr_parse_file( &csr, csr_file ) == 0 );
|
||||||
|
res = x509_csr_info( buf, 2000, "", &csr );
|
||||||
|
|
||||||
|
x509_csr_free( &csr );
|
||||||
|
|
||||||
|
TEST_ASSERT( res != -1 );
|
||||||
|
TEST_ASSERT( res != -2 );
|
||||||
|
|
||||||
|
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CRL_PARSE_C */
|
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CRL_PARSE_C */
|
||||||
void x509_verify( char *crt_file, char *ca_file, char *crl_file,
|
void x509_verify( char *crt_file, char *ca_file, char *crl_file,
|
||||||
char *cn_name_str, int result, int flags_result,
|
char *cn_name_str, int result, int flags_result,
|
||||||
|
|
Loading…
Reference in a new issue