Skip Menu |

This queue is for tickets about the Crypt-OpenSSL-PKCS10 CPAN distribution.

Report information
The Basics
Id: 106286
Status: open
Priority: 0/
Queue: Crypt-OpenSSL-PKCS10

People
Owner: Nobody in particular
Requestors: DDICK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.14
Fixed in: (no value)



Subject: PATCH: get_pubkey support
Hi Ionut, I need this patch applied. Hope it looks all right. Cheers Dave
Subject: pkcs10_get_pubkey.patch
diff -Naur old/PKCS10.pm new/PKCS10.pm --- old/PKCS10.pm 2014-09-17 04:49:27.000000000 +1000 +++ new/PKCS10.pm 2015-08-07 19:42:59.727822217 +1000 @@ -58,6 +58,7 @@ $req->sign(); $req->write_pem_req('request.pem'); $req->write_pem_pk('pk.pem'); + print $req->get_pubkey(); print $req->get_pem_req(); =head1 ABSTRACT @@ -135,6 +136,12 @@ $req->sign(); +=item get_pubkey() + +Returns the PEM encoding of the PKCS10 public key. + + $req->get_pubkey(); + =item get_pem_req() Returns the PEM encoding of the PKCS10 request. diff -Naur old/PKCS10.xs new/PKCS10.xs --- old/PKCS10.xs 2014-09-17 04:48:21.000000000 +1000 +++ new/PKCS10.xs 2015-08-07 19:41:46.128669944 +1000 @@ -417,6 +417,51 @@ RETVAL SV* +get_pubkey(pkcs10) + pkcs10Data *pkcs10; + + PREINIT: + EVP_PKEY *pkey; + BIO *bio; + + CODE: + + pkey = X509_REQ_get_pubkey(pkcs10->req); + bio = sv_bio_create(); + + if (pkey == NULL) { + + BIO_free_all(bio); + EVP_PKEY_free(pkey); + croak("Public Key is unavailable\n"); + } + + if (pkey->type == EVP_PKEY_RSA) { + + PEM_write_bio_RSAPublicKey(bio, pkey->pkey.rsa); + + } else if (pkey->type == EVP_PKEY_DSA) { + + PEM_write_bio_DSA_PUBKEY(bio, pkey->pkey.dsa); +#ifndef OPENSSL_NO_EC + } else if ( pkey->type == EVP_PKEY_EC ) { + PEM_write_bio_EC_PUBKEY(bio, pkey->pkey.ec); +#endif + } else { + + BIO_free_all(bio); + EVP_PKEY_free(pkey); + croak("Wrong Algorithm type\n"); + } + EVP_PKEY_free(pkey); + + RETVAL = sv_bio_final(bio); + + OUTPUT: + RETVAL + + +SV* get_pem_req(pkcs10,...) pkcs10Data *pkcs10; diff -Naur old/t/Mytest.t new/t/Mytest.t --- old/t/Mytest.t 2014-04-18 03:35:14.000000000 +1000 +++ new/t/Mytest.t 2015-08-07 19:42:01.168905453 +1000 @@ -29,6 +29,7 @@ print STDERR $req->get_pem_req(); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->get_pubkey()."\n"; ok($req); } @@ -46,6 +47,7 @@ print STDERR $req->get_pem_req(); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->get_pubkey()."\n"; ok($req); } @@ -53,5 +55,6 @@ my $req = Crypt::OpenSSL::PKCS10->new_from_file("t/CSR.csr"); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->get_pubkey()."\n"; ok($req); }
On Fri Aug 07 20:10:23 2015, DDICK wrote: Show quoted text
> Hi Ionut, > > I need this patch applied. Hope it looks all right. > > Cheers > Dave
Added pubkey_type as a method. :)
Subject: pkcs10_get_pubkey_v2.patch
diff -Naur old/PKCS10.pm new/PKCS10.pm --- old/PKCS10.pm 2014-09-17 04:49:27.000000000 +1000 +++ new/PKCS10.pm 2015-08-08 10:07:00.830343863 +1000 @@ -58,6 +58,8 @@ $req->sign(); $req->write_pem_req('request.pem'); $req->write_pem_pk('pk.pem'); + print $req->get_pem_pubkey(); + print $req->pubkey_type(); print $req->get_pem_req(); =head1 ABSTRACT @@ -135,6 +137,18 @@ $req->sign(); +=item pubkey_type() + +Returns the type of the PKCS10 public key - one of (rsa|dsa|ec). + + $req->pubkey_type(); + +=item get_pubkey() + +Returns the PEM encoding of the PKCS10 public key. + + $req->get_pubkey(); + =item get_pem_req() Returns the PEM encoding of the PKCS10 request. diff -Naur old/PKCS10.xs new/PKCS10.xs --- old/PKCS10.xs 2014-09-17 04:48:21.000000000 +1000 +++ new/PKCS10.xs 2015-08-08 10:07:08.362459160 +1000 @@ -417,6 +417,79 @@ RETVAL SV* +get_pem_pubkey(pkcs10) + pkcs10Data *pkcs10; + + PREINIT: + EVP_PKEY *pkey; + BIO *bio; + + CODE: + + pkey = X509_REQ_get_pubkey(pkcs10->req); + bio = sv_bio_create(); + + if (pkey == NULL) { + + BIO_free_all(bio); + EVP_PKEY_free(pkey); + croak("Public Key is unavailable\n"); + } + + if (pkey->type == EVP_PKEY_RSA) { + +# PEM_write_bio_RSAPublicKey(bio, pkey->pkey.rsa); + PEM_write_bio_RSA_PUBKEY(bio, pkey->pkey.rsa); + + } else if (pkey->type == EVP_PKEY_DSA) { + + PEM_write_bio_DSA_PUBKEY(bio, pkey->pkey.dsa); +#ifndef OPENSSL_NO_EC + } else if ( pkey->type == EVP_PKEY_EC ) { + PEM_write_bio_EC_PUBKEY(bio, pkey->pkey.ec); +#endif + } else { + + BIO_free_all(bio); + EVP_PKEY_free(pkey); + croak("Wrong Algorithm type\n"); + } + EVP_PKEY_free(pkey); + + RETVAL = sv_bio_final(bio); + + OUTPUT: + RETVAL + +char* +pubkey_type(pkcs10) + pkcs10Data *pkcs10; + + PREINIT: + EVP_PKEY *pkey; + + CODE: + RETVAL=NULL; + pkey = X509_REQ_get_pubkey(pkcs10->req); + + if(!pkey) + XSRETURN_UNDEF; + + if (pkey->type == EVP_PKEY_DSA) { + RETVAL="dsa"; + + } else if (pkey->type == EVP_PKEY_RSA) { + RETVAL="rsa"; +#ifndef OPENSSL_NO_EC + } else if ( pkey->type == EVP_PKEY_EC ) { + RETVAL="ec"; +#endif + } + + OUTPUT: + RETVAL + +SV* get_pem_req(pkcs10,...) pkcs10Data *pkcs10; diff -Naur old/t/Mytest.t new/t/Mytest.t --- old/t/Mytest.t 2014-04-18 03:35:14.000000000 +1000 +++ new/t/Mytest.t 2015-08-08 10:05:00.091502205 +1000 @@ -29,6 +29,8 @@ print STDERR $req->get_pem_req(); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->pubkey_type()."\n"; +print STDERR $req->get_pem_pubkey()."\n"; ok($req); } @@ -46,6 +48,8 @@ print STDERR $req->get_pem_req(); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->pubkey_type()."\n"; +print STDERR $req->get_pem_pubkey()."\n"; ok($req); } @@ -53,5 +57,7 @@ my $req = Crypt::OpenSSL::PKCS10->new_from_file("t/CSR.csr"); print STDERR $req->subject()."\n"; print STDERR $req->keyinfo()."\n"; +print STDERR $req->pubkey_type()."\n"; +print STDERR $req->get_pem_pubkey()."\n"; ok($req); }
Subject: Re: [rt.cpan.org #106286] PATCH: get_pubkey support
Date: Sat, 8 Aug 2015 06:22:19 +0000 (UTC)
To: "bug-Crypt-OpenSSL-PKCS10 [...] rt.cpan.org" <bug-Crypt-OpenSSL-PKCS10 [...] rt.cpan.org>
From: J <jonozzz [...] yahoo.com>
0.15 should be out shortly. Thanks! On Friday, August 7, 2015 5:09 PM, David Dick via RT <bug-Crypt-OpenSSL-PKCS10@rt.cpan.org> wrote:       Queue: Crypt-OpenSSL-PKCS10 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=106286 > On Fri Aug 07 20:10:23 2015, DDICK wrote: Show quoted text
> Hi Ionut, > > I need this patch applied.  Hope it looks all right. > > Cheers > Dave
Added pubkey_type as a method. :)