r72062 - in /branches/upstream/libcrypt-openssl-x509-perl/current: Changes META.yml README X509.pm X509.xs t/x509.t typemap

carnil at users.alioth.debian.org carnil at users.alioth.debian.org
Wed Mar 30 11:33:38 UTC 2011


Author: carnil
Date: Wed Mar 30 11:33:23 2011
New Revision: 72062

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72062
Log:
[svn-upgrade] new version libcrypt-openssl-x509-perl (1.7)

Modified:
    branches/upstream/libcrypt-openssl-x509-perl/current/Changes
    branches/upstream/libcrypt-openssl-x509-perl/current/META.yml
    branches/upstream/libcrypt-openssl-x509-perl/current/README
    branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm
    branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs
    branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t
    branches/upstream/libcrypt-openssl-x509-perl/current/typemap

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/Changes?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/Changes (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/Changes Wed Mar 30 11:33:23 2011
@@ -1,4 +1,7 @@
 Revision history for Perl extension Crypt::OpenSSL::X509.
+
+1.7    Tue Mar 29 19:58:08 PDT 2011
+	- Updates from David O'Callaghan to add pubkey, encoding & CRL functions.
 
 1.6    Wed Jan  5 10:04:08 PST 2011
 	- Fix from Nicholas Harteau for -Wall error. Exhibited by -O2.

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/META.yml?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/META.yml (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/META.yml Wed Mar 30 11:33:23 2011
@@ -23,4 +23,4 @@
   bugtracker: https://github.com/dsully/perl-crypt-openssl-x509/issues
   homepage: https://github.com/dsully/perl-crypt-openssl-x509
   license: http://dev.perl.org/licenses/
-version: 1.6
+version: 1.7

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/README?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/README (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/README Wed Mar 30 11:33:23 2011
@@ -1,4 +1,4 @@
-Crypt/OpenSSL/X509 version 1.6
+Crypt/OpenSSL/X509 version 1.7
 ===============================
 
 The README is used to introduce the module and provide instructions on

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/X509.pm Wed Mar 30 11:33:23 2011
@@ -5,7 +5,7 @@
 use Exporter;
 use base qw(Exporter);
 
-$VERSION = '1.6';
+$VERSION = '1.7';
 
 @EXPORT_OK = qw(
   FORMAT_UNDEF FORMAT_ASN1 FORMAT_TEXT FORMAT_PEM FORMAT_NETSCAPE
@@ -82,6 +82,11 @@
   return @vals;
 }
 
+sub Crypt::OpenSSL::X509::is_selfsigned {
+  my $x509 = shift;
+
+  return $x509->subject eq $x509->issuer;
+}
 
 BOOT_XS: {
   require DynaLoader;
@@ -236,6 +241,10 @@
 
 Return a Name object for the subject or issuer name. Methods for handling Name objects are given below.
 
+=item is_selfsigned ( )
+
+Return Boolean value if subject and issuer name are the same.
+
 =item as_string ( [ FORMAT ] )
 
 Return the certificate as a string in the specified format. C<FORMAT> can be one of C<FORMAT_PEM> (the default), C<FORMAT_ASN1>, or C<FORMAT_NETSCAPE>.

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/X509.xs Wed Mar 30 11:33:23 2011
@@ -31,6 +31,7 @@
 typedef ASN1_OBJECT* Crypt__OpenSSL__X509__ObjectID;
 typedef X509_NAME* Crypt__OpenSSL__X509__Name;
 typedef X509_NAME_ENTRY* Crypt__OpenSSL__X509__Name_Entry;
+typedef X509_CRL* Crypt__OpenSSL__X509__CRL;
 
 /* 1.0 backwards compat */
 #ifndef sk_OPENSSL_STRING_num
@@ -104,14 +105,14 @@
     const U8* cur;
 
     while ((start < end) && !is_utf8_string_loclen(start, len, &cur, 0)) {
-      sv_catpvn(nsv, (const char*)start, (cur - start) - 1);	/* text that was ok */
-      sv_catpvn(nsv, (const char*)utf8_substitute_char, 3);	/* insert \x{fffd} */
+      sv_catpvn(nsv, (const char*)start, (cur - start) - 1);  /* text that was ok */
+      sv_catpvn(nsv, (const char*)utf8_substitute_char, 3);  /* insert \x{fffd} */
       start = cur + 1;
       len = end - cur;
     }
 
     if (start < end) {
-      sv_catpvn(nsv, (const char*)start, (cur - start) - 1);	/* rest of the string */
+      sv_catpvn(nsv, (const char*)start, (cur - start) - 1);  /* rest of the string */
     }
 
     sv_copypv(sv, nsv);
@@ -681,6 +682,37 @@
   OUTPUT:
   RETVAL
 
+SV*
+pub_exponent(x509)
+    Crypt::OpenSSL::X509 x509
+  PREINIT:
+    EVP_PKEY *pkey;
+    BIO *bio;
+  CODE:
+    bio = sv_bio_create();
+    pkey = X509_get_pubkey(x509);
+    BN_print(bio,pkey->pkey.rsa->e);
+    RETVAL = sv_bio_final(bio);
+  OUTPUT:
+  RETVAL
+
+char*
+pubkey_type(x509)
+        Crypt::OpenSSL::X509 x509;
+    PREINIT:
+        EVP_PKEY *pkey;
+    CODE:
+        RETVAL=NULL;
+        pkey = X509_get_pubkey(x509);
+        if(pkey->type == EVP_PKEY_DSA){
+            RETVAL="dsa";
+        }
+        else if(pkey->type == EVP_PKEY_RSA){
+            RETVAL="rsa";
+        }
+    OUTPUT:
+    RETVAL
+
 int
 num_extensions(x509)
   Crypt::OpenSSL::X509 x509;
@@ -1232,3 +1264,98 @@
 
   OUTPUT:
   RETVAL
+
+char*
+encoding(name_entry)
+  Crypt::OpenSSL::X509::Name_Entry name_entry;
+
+  CODE:
+  RETVAL = NULL;
+
+  if (X509_NAME_ENTRY_get_data(name_entry)->type == V_ASN1_PRINTABLESTRING) {
+    RETVAL = "printableString";
+
+  } else if(X509_NAME_ENTRY_get_data(name_entry)->type == V_ASN1_IA5STRING) {
+    RETVAL = "ia5String";
+
+  } else if(X509_NAME_ENTRY_get_data(name_entry)->type == V_ASN1_UTF8STRING) {
+    RETVAL = "utf8String";
+  }
+
+  OUTPUT:
+  RETVAL
+
+MODULE = Crypt::OpenSSL::X509       PACKAGE = Crypt::OpenSSL::X509_CRL
+
+Crypt::OpenSSL::X509::CRL
+new_from_crl_string(class, string, format = FORMAT_PEM)
+  SV  *class;
+  SV  *string;
+  int format;
+
+  ALIAS:
+  new_from_crl_file = 1
+
+  PREINIT:
+  BIO *bio;
+  STRLEN len;
+  char *crl;
+
+  CODE:
+
+  crl = SvPV(string, len);
+
+  if (ix == 1) {
+    bio = BIO_new_file(crl, "r");
+  } else {
+    bio = BIO_new_mem_buf(crl, len);
+  }
+
+  if (!bio) {
+    croak("%s: Failed to create BIO", class);
+  }
+
+  if (format == FORMAT_ASN1) {
+    RETVAL = (X509_CRL*)d2i_X509_CRL_bio(bio, NULL);
+  } else {
+    RETVAL = (X509_CRL*)PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL);
+  }
+
+  if (!RETVAL) {
+    croak("%s: failed to read X509 certificate.", SvPV_nolen(class));
+  }
+
+  BIO_free(bio);
+
+  OUTPUT:
+  RETVAL
+
+SV*
+CRL_accessor(crl)
+  Crypt::OpenSSL::X509::CRL crl;
+
+  ALIAS:
+  CRL_issuer = 1
+  CRL_sig_alg_name = 2
+
+  PREINIT:
+  BIO *bio;
+  X509_NAME *name;
+
+  CODE:
+  bio = sv_bio_create();
+
+  if (ix == 1) {
+    name = X509_CRL_get_issuer(crl);
+    sv_bio_utf8_on(bio);
+    X509_NAME_print_ex(bio, name, 0, (XN_FLAG_SEP_CPLUS_SPC | ASN1_STRFLGS_UTF8_CONVERT) & ~ASN1_STRFLGS_ESC_MSB);
+    RETVAL = sv_bio_final(bio);
+
+  } else if (ix == 2) {
+    i2a_ASN1_OBJECT(bio, crl->sig_alg->algorithm);
+  }
+
+  RETVAL = sv_bio_final(bio);
+
+  OUTPUT:
+  RETVAL

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/t/x509.t Wed Mar 30 11:33:23 2011
@@ -1,5 +1,5 @@
 
-use Test::More tests => 46;
+use Test::More tests => 49;
 
 BEGIN { use_ok('Crypt::OpenSSL::X509') };
 
@@ -15,6 +15,8 @@
 
 ok($x509->issuer() eq 'C=US, O=VeriSign, Inc., OU=Class 1 Public Primary Certification Authority', 'issuer()');
 ok($x509->subject() eq 'C=US, O=VeriSign, Inc., OU=Class 1 Public Primary Certification Authority', 'subject()');
+
+ok($x509->is_selfsigned(), 'is_selfsigned()');
 
 # For some reason the hash hash changed with v1.0.0
 # Verified with the openssl binary.
@@ -36,7 +38,7 @@
 
 ok($x509->num_extensions() eq '1', 'num_extensions()');
 
-ok(my $exts = $x509->extensions_by_oid(), 'extension_by_oid()');
+ok($exts = $x509->extensions_by_oid(), 'extension_by_oid()');
 
 ok($x509->has_extension_oid("2.5.29.19"), 'has_extension_oid(2.5.29.19)');
 
@@ -48,7 +50,12 @@
 ok($x509_b = Crypt::OpenSSL::X509->new_from_file('certs/balt.pem'), 'new_from_file()');
 ok(my $exts_b = $x509_b->extensions_by_name(), "extensions_by_name()");
 ok(not($$exts_b{'subjectKeyIdentifier'}->is_critical()), "subjectKeyIdentifier not critical");
+my $subkeyid = (join ":", map{sprintf "%X", ord($_)} split //, $$exts_b{'subjectKeyIdentifier'}->keyid_data());
+ok($subkeyid eq "E5:9D:59:30:82:47:58:CC:AC:FA:8:54:36:86:7B:3A:B5:4:4D:F0", "Extension{subjectKeyID}->keyid_data()");
+
 ok($$exts_b{'keyUsage'}->is_critical(), "keyUsage is critical");
+my %key_hash = $$exts_b{'keyUsage'}->hash_bit_string();
+ok($key_hash{'Certificate Sign'}, "Extension->hash_bit_string()");
 
 isa_ok($x509->subject_name(), "Crypt::OpenSSL::X509::Name", 'subject_name()');
 isa_ok($x509->issuer_name(), "Crypt::OpenSSL::X509::Name", 'issuer_name()');

Modified: branches/upstream/libcrypt-openssl-x509-perl/current/typemap
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcrypt-openssl-x509-perl/current/typemap?rev=72062&op=diff
==============================================================================
--- branches/upstream/libcrypt-openssl-x509-perl/current/typemap (original)
+++ branches/upstream/libcrypt-openssl-x509-perl/current/typemap Wed Mar 30 11:33:23 2011
@@ -4,3 +4,4 @@
 Crypt::OpenSSL::X509::ObjectID T_PTROBJ
 Crypt::OpenSSL::X509::Name T_PTROBJ
 Crypt::OpenSSL::X509::Name_Entry T_PTROBJ
+Crypt::OpenSSL::X509::CRL T_PTROBJ




More information about the Pkg-perl-cvs-commits mailing list