… | |
… | |
91 | } |
91 | } |
92 | sv_setpv(sv, buf); |
92 | sv_setpv(sv, buf); |
93 | return sv; |
93 | return sv; |
94 | } |
94 | } |
95 | |
95 | |
96 | long fuck_cb(struct bio_st *bm, int m, const char *ptr, int l, long x, long y) |
96 | long bio_write_cb(struct bio_st *bm, int m, const char *ptr, int l, long x, long y) |
97 | { |
97 | { |
98 | if(m == BIO_CB_WRITE) { |
98 | if(m == BIO_CB_WRITE) { |
99 | SV *sv = (SV *) BIO_get_callback_arg(bm); |
99 | SV *sv = (SV *) BIO_get_callback_arg(bm); |
100 | sv_catpvn(sv, ptr, l); |
100 | sv_catpvn(sv, ptr, l); |
101 | } |
101 | } |
… | |
… | |
113 | BIO *bio; |
113 | BIO *bio; |
114 | sv = newSVpvn("",0); |
114 | sv = newSVpvn("",0); |
115 | // mem is completely broken for write, so we use /dev/null |
115 | // mem is completely broken for write, so we use /dev/null |
116 | // and use callbacks-hooks |
116 | // and use callbacks-hooks |
117 | bio = BIO_new_file("/dev/null", "wb"); |
117 | bio = BIO_new_file("/dev/null", "wb"); |
118 | BIO_set_callback(bio, fuck_cb); |
118 | BIO_set_callback(bio, bio_write_cb); |
119 | BIO_set_callback_arg(bio, (void *)sv); |
119 | BIO_set_callback_arg(bio, (void *)sv); |
120 | return bio; |
120 | return bio; |
121 | } |
121 | } |
122 | |
122 | |
123 | static inline BIO *sv_bio_create_file(SV *filename) |
123 | static inline BIO *sv_bio_create_file(SV *filename) |
124 | { |
124 | { |
125 | char *fn; |
|
|
126 | STRLEN l; |
125 | STRLEN l; |
127 | |
126 | |
128 | return BIO_new_file(SvPV(filename, l), "wb"); |
127 | return BIO_new_file(SvPV(filename, l), "wb"); |
129 | } |
128 | } |
130 | |
129 | |
… | |
… | |
292 | sprintf(&s[i*3], "%02X%c", md[i], (i + 1 == (int) n) ? '\0' : ':'); |
291 | sprintf(&s[i*3], "%02X%c", md[i], (i + 1 == (int) n) ? '\0' : ':'); |
293 | } |
292 | } |
294 | return s; |
293 | return s; |
295 | } |
294 | } |
296 | |
295 | |
297 | static inline char *ol(X509_NAME *x) |
296 | static inline SV *ol(X509_NAME *x) |
298 | { |
297 | { |
299 | static char buf[256]; |
298 | char *p; |
300 | X509_NAME_oneline(x, buf, 256); |
299 | SV *sv = newSVpvn("",0); |
|
|
300 | X509_NAME_oneline(x, (p=SvGROW(sv,8192)), 8192); |
|
|
301 | SvCUR_set(sv, strlen(p)); |
301 | return buf; |
302 | return sv; |
302 | } |
303 | } |
303 | |
304 | |
|
|
305 | #if 0 |
304 | static void run_sha1(char *digest, const char *msg, int msglen) |
306 | static void run_sha1(char *digest, const char *msg, int msglen) |
305 | { |
307 | { |
306 | SHA_CTX ctx; |
308 | SHA_CTX ctx; |
307 | |
309 | |
308 | if(!digest || !msg || msglen < 0) |
310 | if(!digest || !msg || msglen < 0) |
309 | croak("run_sha1: null pointer or illegal message len"); |
311 | croak("run_sha1: null pointer or illegal message len"); |
310 | SHA1_Init(&ctx); |
312 | SHA1_Init(&ctx); |
311 | SHA1_Update(&ctx, msg, msglen); |
313 | SHA1_Update(&ctx, msg, msglen); |
312 | SHA1_Final(digest, &ctx); |
314 | SHA1_Final(digest, &ctx); |
313 | } |
315 | } |
314 | |
316 | #endif |
315 | static bool is_privkey(RSA *key) |
317 | static bool is_privkey(RSA *key) |
316 | { |
318 | { |
317 | return (key->n && key->e && key->d && key->p && key->q |
319 | return (key->n && key->e && key->d && key->p && key->q |
318 | && key->dmp1 && key->dmq1 && key->iqmp && key->d) ? 1 : 0; |
320 | && key->dmp1 && key->dmq1 && key->iqmp && key->d) ? 1 : 0; |
319 | } |
321 | } |
… | |
… | |
592 | void |
594 | void |
593 | STORABLE_freeze(key, cloning) |
595 | STORABLE_freeze(key, cloning) |
594 | OpenSSL::RSA key |
596 | OpenSSL::RSA key |
595 | bool cloning |
597 | bool cloning |
596 | PREINIT: |
598 | PREINIT: |
597 | SV *sv; |
|
|
598 | STRLEN totlen; |
599 | STRLEN totlen; |
599 | PPCODE: |
600 | PPCODE: |
600 | if(cloning) |
601 | if(cloning) |
601 | return; |
602 | return; |
602 | totlen = BN_num_bytes(key->n) + BN_num_bytes(key->e) + 3*sizeof(int); |
603 | totlen = BN_num_bytes(key->n) + BN_num_bytes(key->e) + 3*sizeof(int); |
… | |
… | |
892 | ALIAS: |
893 | ALIAS: |
893 | new_from_file = 1 |
894 | new_from_file = 1 |
894 | PREINIT: |
895 | PREINIT: |
895 | BIO *bio; |
896 | BIO *bio; |
896 | STRLEN l; |
897 | STRLEN l; |
897 | char *p, *q = 0; |
898 | char *p; |
898 | CODE: |
899 | CODE: |
899 | p = SvPV (thing, l); |
900 | p = SvPV (thing, l); |
900 | if(ix == 1) { |
901 | if(ix == 1) { |
901 | bio = BIO_new_file(p, "r"); |
902 | bio = BIO_new_file(p, "r"); |
902 | } else { |
903 | } else { |
… | |
… | |
941 | |
942 | |
942 | OpenSSL::Name |
943 | OpenSSL::Name |
943 | subject(x509) |
944 | subject(x509) |
944 | OpenSSL::X509 x509 |
945 | OpenSSL::X509 x509 |
945 | CODE: |
946 | CODE: |
946 | RETVAL = X509_get_subject_name(x509); |
947 | RETVAL = X509_NAME_dup (X509_get_subject_name(x509)); |
947 | OUTPUT: |
948 | OUTPUT: |
948 | RETVAL |
949 | RETVAL |
949 | |
950 | |
950 | OpenSSL::Name |
951 | OpenSSL::Name |
951 | issuer(x509) |
952 | issuer(x509) |
952 | OpenSSL::X509 x509 |
953 | OpenSSL::X509 x509 |
953 | CODE: |
954 | CODE: |
954 | RETVAL = X509_get_issuer_name(x509); |
955 | RETVAL = X509_NAME_dup (X509_get_issuer_name(x509)); |
955 | OUTPUT: |
956 | OUTPUT: |
956 | RETVAL |
957 | RETVAL |
957 | |
958 | |
958 | |
959 | |
959 | char * |
960 | SV * |
960 | subject_txt(x509) |
961 | subject_txt(x509) |
961 | OpenSSL::X509 x509 |
962 | OpenSSL::X509 x509 |
962 | CODE: |
963 | CODE: |
963 | RETVAL = ol(X509_get_subject_name(x509)); |
964 | RETVAL = ol(X509_get_subject_name(x509)); |
964 | OUTPUT: |
965 | OUTPUT: |
965 | RETVAL |
966 | RETVAL |
966 | |
967 | |
967 | |
968 | |
968 | char * |
969 | SV * |
969 | issuer_txt(x509) |
970 | issuer_txt(x509) |
970 | OpenSSL::X509 x509 |
971 | OpenSSL::X509 x509 |
971 | CODE: |
972 | CODE: |
972 | RETVAL = ol(X509_get_issuer_name(x509)); |
973 | RETVAL = ol(X509_get_issuer_name(x509)); |
973 | OUTPUT: |
974 | OUTPUT: |
… | |
… | |
1367 | dss_base64 = 0x25 |
1368 | dss_base64 = 0x25 |
1368 | dss1_base64 = 0x26 |
1369 | dss1_base64 = 0x26 |
1369 | mdc2_base64 = 0x27 |
1370 | mdc2_base64 = 0x27 |
1370 | ripemd160_base64 = 0x28 |
1371 | ripemd160_base64 = 0x28 |
1371 | PREINIT: |
1372 | PREINIT: |
1372 | HMAC_CTX ctx; |
|
|
1373 | STRLEN l, keylen; |
1373 | STRLEN l, keylen; |
1374 | char *p; |
1374 | char *p; |
1375 | char *key; |
1375 | char *key; |
1376 | unsigned char md[EVP_MAX_MD_SIZE]; |
1376 | unsigned char md[EVP_MAX_MD_SIZE]; |
1377 | unsigned int md_len; |
1377 | unsigned int md_len; |
… | |
… | |
1553 | OpenSSL::PKCS12 p12 |
1553 | OpenSSL::PKCS12 p12 |
1554 | ALIAS: |
1554 | ALIAS: |
1555 | as_file = 1 |
1555 | as_file = 1 |
1556 | PROTOTYPE: $;$ |
1556 | PROTOTYPE: $;$ |
1557 | PREINIT: |
1557 | PREINIT: |
1558 | SV *sv; |
|
|
1559 | BIO *bio; |
1558 | BIO *bio; |
1560 | CODE: |
1559 | CODE: |
1561 | if((ix != 1 && items > 1) || (ix == 1 && items != 2)) |
1560 | if((ix != 1 && items > 1) || (ix == 1 && items != 2)) |
1562 | croak("OpenSSL::PKCS12::%s: illegal/missing args", (ix == 1) ? "as_file" : "as_string"); |
1561 | croak("OpenSSL::PKCS12::%s: illegal/missing args", (ix == 1) ? "as_file" : "as_string"); |
1563 | if(items > 1) { |
1562 | if(items > 1) { |
… | |
… | |
1586 | |
1585 | |
1587 | |
1586 | |
1588 | MODULE = OpenSSL PACKAGE = OpenSSL::CRL |
1587 | MODULE = OpenSSL PACKAGE = OpenSSL::CRL |
1589 | |
1588 | |
1590 | OpenSSL::CRL |
1589 | OpenSSL::CRL |
1591 | new_from_string(thing) |
1590 | new_from_string(class,thing) |
|
|
1591 | SV *class |
1592 | SV *thing |
1592 | SV *thing |
1593 | ALIAS: |
1593 | ALIAS: |
1594 | new_from_file = 1 |
1594 | new_from_file = 1 |
1595 | PREINIT: |
1595 | PREINIT: |
1596 | BIO *bio; |
1596 | BIO *bio; |
1597 | STRLEN l; |
1597 | STRLEN l; |
1598 | char *p, *q = 0; |
1598 | char *p; |
1599 | CODE: |
1599 | CODE: |
1600 | p = SvPV(thing, l); |
1600 | p = SvPV(thing, l); |
1601 | if(ix == 1) { |
1601 | if(ix == 1) { |
1602 | bio = BIO_new_file(p, "r"); |
1602 | bio = BIO_new_file(p, "r"); |
1603 | } else { |
1603 | } else { |