SSL.xs

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 67 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/POE/Filter/SSL/PreFilter.pm ↑ Summary
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include "ppport.h"
5  
6 #include <openssl/ssl.h>
7 #include <openssl/bio.h>
8  
9 #if OPENSSL_VERSION_NUMBER < 0x10100000
10 static const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x)
11 {
12 return x->serialNumber;
13 }
14 #endif
15  
16 MODULE = POE::Filter::SSL PACKAGE = POE::Filter::SSL
17  
18 long
19 POE_FILTER_SSL_set_tmp_dh(ssl,dh)
20 SSL * ssl
21 DH * dh
22 CODE:
23 0 RETVAL = SSL_set_tmp_dh(ssl,dh);
24 OUTPUT:
25 RETVAL
26  
27 long
28 POE_FILTER_SSL_CTX_set_tmp_dh(ctx,dh)
29 SSL_CTX * ctx
30 DH * dh
31 CODE:
32 0 RETVAL = SSL_CTX_set_tmp_dh(ctx,dh);
33 OUTPUT:
34 RETVAL
35  
36 long
37 POE_FILTER_SSL_CTX_set_tmp_rsa(ctx,rsa)
38 SSL_CTX * ctx
39 RSA * rsa
40 CODE:
41 0 ▶ RETVAL = SSL_CTX_set_tmp_rsa(ctx,rsa);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = SSL_CTX_set_tmp_rsa(ctx,rsa); 0 0 0
42 OUTPUT:
43 RETVAL
44  
45 int
46 POE_FILTER_SSL_get_ex_data_X509_STORE_CTX_idx()
47 CODE:
48 0 RETVAL = SSL_get_ex_data_X509_STORE_CTX_idx();
49 OUTPUT:
50 RETVAL
51  
52 ASN1_INTEGER *
53 POE_FILTER_X509_get_serialNumber(cert)
54 X509 * cert
55 CODE:
56 0 RETVAL = X509_get_serialNumber(cert);
57 0 ST(0) = sv_newmortal(); /* Undefined to start with */
58 0 sv_setpvn( ST(0), RETVAL->data, RETVAL->length);
59  
60 ASN1_INTEGER *
61 POE_FILTER_verify_serial_against_crl_file(crlfile, serial)
62 CODE:
63 0 X509_CRL *crl=NULL;
64 X509_REVOKED *revoked;
65 STACK_OF(X509_REVOKED) *revokes;
66 0 BIO *in=NULL;
67 0 int n,i,retval = 0;
68 STRLEN len, lenser;
69 0 unsigned char* crlfile = SvPV( ST(0), len);
70 0 ▶ unsigned char* serial = SvPV( ST(1), lenser);
Branch: 1 branch
BranchTrueFalseTotal
unsigned char* serial = SvPV( ST(1), lenser); 0 0 0
71 0 ST(0) = sv_newmortal(); /* Undefined to start with */
72  
73 /* check peer cert against CRL */
74 0 ▶ if (len <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (len <= 0) { 0 0 0
75 0 sv_setpvn(ST(0), "CRL: No file name given!", 24);
76 0 goto end;
77 }
78  
79 0 in=BIO_new(BIO_s_file());
80 0 ▶ if (in == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (in == NULL) { 0 0 0
81 0 sv_setpvn(ST(0), "CRL: BIO err", 12);
82 0 goto end;
83 }
84  
85 0 ▶ if (BIO_read_filename(in, crlfile) <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (BIO_read_filename(in, crlfile) <= 0) { 0 0 0
86 0 sv_setpvn(ST(0), "CRL: cannot read CRL File", 25);
87 0 goto end;
88 }
89  
90 0 crl=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
91 0 ▶ if (crl == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (crl == NULL) { 0 0 0
92 0 sv_setpvn(ST(0), "CRL: cannot read from CRL File", 30);
93 0 goto end;
94 }
95  
96 0 revokes = X509_CRL_get_REVOKED(crl);
97 0 n = sk_X509_REVOKED_num(revokes);
98 0 ▶ if (n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n > 0) { 0 0 0
99 0 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 0 0 0
100 const ASN1_INTEGER *asn_ser;
101  
102 0 revoked = sk_X509_REVOKED_value(revokes, i);
103 0 asn_ser = X509_REVOKED_get0_serialNumber(revoked);
104 0 ▶ if ( (asn_ser->length > 0) &&
Branch: 1 branch
BranchTrueFalseTotal
if ( (asn_ser->length > 0) && 0 0 0
105 0 ▶ (asn_ser->length == lenser) &&
Branch: 1 branch
BranchTrueFalseTotal
(asn_ser->length == lenser) && 0 0 0
106 0 ▶ (strncmp(asn_ser->data, serial, lenser) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
(strncmp(asn_ser->data, serial, lenser) == 0)) { 0 0 0
107 0 sv_setpvn( ST(0), asn_ser->data, asn_ser->length);
108 0 goto end;
109 }
110 }
111 0 sv_setpvn(ST(0), "0", 1);
112 } else {
113 0 sv_setpvn(ST(0), "CRL: Empty File", 15);
114 }
115 0 end:
116 0 BIO_free(in);
117 0 ▶ if (crl) X509_CRL_free (crl);
Branch: 1 branch
BranchTrueFalseTotal
if (crl) X509_CRL_free (crl); 0 0 0
« blib/lib/POE/Filter/SSL/PreFilter.pm ↑ Summary