diff options
author | Jean-Paul Calderone <exarkun@divmod.com> | 2011-04-18 11:02:54 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@divmod.com> | 2011-04-18 11:02:54 -0400 |
commit | dc77b20c86bf0b38a7a082df31a2cedadc81fe00 (patch) | |
tree | 29616cbdf4fba7852ba8c3840f339c1563c18b41 /OpenSSL/crypto | |
parent | d07d57d7da05008a16e9c065240dc92f696650c2 (diff) | |
parent | 5091e7869f59d793c802c6c6cb9df783c5e85c94 (diff) | |
download | pyopenssl-dc77b20c86bf0b38a7a082df31a2cedadc81fe00.tar.gz |
Catch up to trunk
Diffstat (limited to 'OpenSSL/crypto')
-rw-r--r-- | OpenSSL/crypto/crypto.c | 7 | ||||
-rw-r--r-- | OpenSSL/crypto/crypto.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/netscape_spki.c | 3 | ||||
-rw-r--r-- | OpenSSL/crypto/netscape_spki.h | 3 | ||||
-rw-r--r-- | OpenSSL/crypto/pkcs12.c | 3 | ||||
-rw-r--r-- | OpenSSL/crypto/pkcs12.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/pkcs7.c | 3 | ||||
-rw-r--r-- | OpenSSL/crypto/pkcs7.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/pkey.c | 5 | ||||
-rw-r--r-- | OpenSSL/crypto/pkey.h | 6 | ||||
-rw-r--r-- | OpenSSL/crypto/x509.c | 56 | ||||
-rw-r--r-- | OpenSSL/crypto/x509.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/x509ext.c | 25 | ||||
-rw-r--r-- | OpenSSL/crypto/x509ext.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/x509name.c | 5 | ||||
-rw-r--r-- | OpenSSL/crypto/x509name.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/x509req.c | 5 | ||||
-rw-r--r-- | OpenSSL/crypto/x509req.h | 4 | ||||
-rw-r--r-- | OpenSSL/crypto/x509store.c | 3 | ||||
-rw-r--r-- | OpenSSL/crypto/x509store.h | 4 |
20 files changed, 118 insertions, 38 deletions
diff --git a/OpenSSL/crypto/crypto.c b/OpenSSL/crypto/crypto.c index 1a122b2..1e2abc2 100644 --- a/OpenSSL/crypto/crypto.c +++ b/OpenSSL/crypto/crypto.c @@ -1,9 +1,10 @@ /* * crypto.c * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Keyphrene 2004, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008-2009, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Keyphrene + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * Main file of crypto sub module. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/crypto.h b/OpenSSL/crypto/crypto.h index e42a3a3..35fbe74 100644 --- a/OpenSSL/crypto/crypto.h +++ b/OpenSSL/crypto/crypto.h @@ -1,14 +1,14 @@ /* * crypto.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Exports from crypto.c. * See the file RATIONALE for a short explanation of why this module was written. * * Reviewed 2001-07-23 * - * @(#) $Id: crypto.h,v 1.14 2004/08/09 13:41:25 martin Exp $ */ #ifndef PyOpenSSL_CRYPTO_H_ #define PyOpenSSL_CRYPTO_H_ diff --git a/OpenSSL/crypto/netscape_spki.c b/OpenSSL/crypto/netscape_spki.c index 183a0ee..b209fae 100644 --- a/OpenSSL/crypto/netscape_spki.c +++ b/OpenSSL/crypto/netscape_spki.c @@ -1,7 +1,8 @@ /* * netscape_spki.c * - * Copyright (C) Tollef Fog Heen 2003 + * Copyright (C) Tollef Fog Heen + * See LICENSE for details. * * Netscape SPKI handling, thin wrapper */ diff --git a/OpenSSL/crypto/netscape_spki.h b/OpenSSL/crypto/netscape_spki.h index 19389d8..2f07307 100644 --- a/OpenSSL/crypto/netscape_spki.h +++ b/OpenSSL/crypto/netscape_spki.h @@ -1,7 +1,8 @@ /* * netscape_spki.h * - * Copyright (C) Tollef Fog Heen 2003, All rights reserved + * Copyright (C) Tollef Fog Heen + * See LICENSE for details. * * Handle Netscape SPKI (challenge response) certificate requests. * diff --git a/OpenSSL/crypto/pkcs12.c b/OpenSSL/crypto/pkcs12.c index c3fc816..7eed1f5 100644 --- a/OpenSSL/crypto/pkcs12.c +++ b/OpenSSL/crypto/pkcs12.c @@ -1,7 +1,8 @@ /* * pkcs12.c * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Certificate transport (PKCS12) handling code, * mostly thin wrappers around OpenSSL. diff --git a/OpenSSL/crypto/pkcs12.h b/OpenSSL/crypto/pkcs12.h index 3abfa52..f0de1a8 100644 --- a/OpenSSL/crypto/pkcs12.h +++ b/OpenSSL/crypto/pkcs12.h @@ -1,11 +1,11 @@ /* * pkcs12.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export PKCS12 functions and data structure. * - * @(#) $$ */ #ifndef PyOpenSSL_crypto_PKCS12_H_ #define PyOpenSSL_crypto_PKCS12_H_ diff --git a/OpenSSL/crypto/pkcs7.c b/OpenSSL/crypto/pkcs7.c index fff95e2..a074800 100644 --- a/OpenSSL/crypto/pkcs7.c +++ b/OpenSSL/crypto/pkcs7.c @@ -1,7 +1,8 @@ /* * pkcs7.c * - * Copyright (C) AB Strakt 2002, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * PKCS7 handling code, mostly thin wrappers around OpenSSL. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/pkcs7.h b/OpenSSL/crypto/pkcs7.h index bdbb425..d8453b2 100644 --- a/OpenSSL/crypto/pkcs7.h +++ b/OpenSSL/crypto/pkcs7.h @@ -1,12 +1,12 @@ /* * pkcs7.h * - * Copyright (C) AB Strakt 2002, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export pkcs7 functions and data structure. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: pkcs7.h,v 1.2 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_crypto_PKCS7_H_ #define PyOpenSSL_crypto_PKCS7_H_ diff --git a/OpenSSL/crypto/pkey.c b/OpenSSL/crypto/pkey.c index 2591f13..fd6c735 100644 --- a/OpenSSL/crypto/pkey.c +++ b/OpenSSL/crypto/pkey.c @@ -1,8 +1,9 @@ /* * pkey.c * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * Public/rivate key handling code, mostly thin wrappers around OpenSSL. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/pkey.h b/OpenSSL/crypto/pkey.h index 3ac7bde..dc5e52e 100644 --- a/OpenSSL/crypto/pkey.h +++ b/OpenSSL/crypto/pkey.h @@ -1,13 +1,13 @@ /* * pkey.h * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * Export pkey functions and data structure. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: pkey.h,v 1.5 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_crypto_PKEY_H_ #define PyOpenSSL_crypto_PKEY_H_ diff --git a/OpenSSL/crypto/x509.c b/OpenSSL/crypto/x509.c index 937d159..5d2a2e6 100644 --- a/OpenSSL/crypto/x509.c +++ b/OpenSSL/crypto/x509.c @@ -1,8 +1,9 @@ /* * x509.c * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * Certificate (X.509) handling code, mostly thin wrappers around OpenSSL. * See the file RATIONALE for a short explanation of why this module was written. @@ -12,6 +13,7 @@ #include <Python.h> #define crypto_MODULE #include "crypto.h" +#include "x509ext.h" /* * X.509 is a standard for digital certificates. See e.g. the OpenSSL homepage @@ -299,7 +301,7 @@ crypto_X509_get_pubkey(crypto_X509Obj *self, PyObject *args) py_pkey = crypto_PKey_New(pkey, 1); if (py_pkey != NULL) { - py_pkey->only_public = 1; + py_pkey->only_public = 1; } return (PyObject *)py_pkey; } @@ -684,6 +686,52 @@ crypto_X509_add_extensions(crypto_X509Obj *self, PyObject *args) return Py_None; } +static char crypto_X509_get_extension_count_doc[] = "\n\ +Get the number of extensions on the certificate.\n\ +\n\ +@return: Number of extensions as a Python integer\n\ +"; + +static PyObject * +crypto_X509_get_extension_count(crypto_X509Obj *self, PyObject *args) { + if (!PyArg_ParseTuple(args, ":get_extension_count")) { + return NULL; + } + + return PyLong_FromLong((long)X509_get_ext_count(self->x509)); +} + +static char crypto_X509_get_extension_doc[] = "\n\ +Get a specific extension of the certificate by index.\n\ +\n\ +@param index: The index of the extension to retrieve.\n\ +@return: The X509Extension object at the specified index.\n\ +"; + +static PyObject * +crypto_X509_get_extension(crypto_X509Obj *self, PyObject *args) { + crypto_X509ExtensionObj *extobj; + int loc; + X509_EXTENSION *ext; + + if (!PyArg_ParseTuple(args, "i:get_extension", &loc)) { + return NULL; + } + + /* will return NULL if loc is outside the range of extensions, + not registered as an error*/ + ext = X509_get_ext(self->x509, loc); + if (!ext) { + PyErr_SetString(PyExc_IndexError, "extension index out of bounds"); + return NULL; /* Should be reported as an IndexError ? */ + } + + extobj = PyObject_New(crypto_X509ExtensionObj, &crypto_X509Extension_Type); + extobj->x509_extension = X509_EXTENSION_dup(ext); + + return (PyObject*)extobj; +} + /* * ADD_METHOD(name) expands to a correct PyMethodDef declaration * { 'name', (PyCFunction)crypto_X509_name, METH_VARARGS } @@ -714,6 +762,8 @@ static PyMethodDef crypto_X509_methods[] = ADD_METHOD(subject_name_hash), ADD_METHOD(digest), ADD_METHOD(add_extensions), + ADD_METHOD(get_extension), + ADD_METHOD(get_extension_count), { NULL, NULL } }; #undef ADD_METHOD diff --git a/OpenSSL/crypto/x509.h b/OpenSSL/crypto/x509.h index 43e41eb..f6cd190 100644 --- a/OpenSSL/crypto/x509.h +++ b/OpenSSL/crypto/x509.h @@ -1,14 +1,14 @@ /* * x509.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export x509 functions and data structure. * See the file RATIONALE for a short explanation of why this module was written. * * Reviewed 2001-07-23 * - * @(#) $Id: x509.h,v 1.9 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_crypto_X509_H_ #define PyOpenSSL_crypto_X509_H_ diff --git a/OpenSSL/crypto/x509ext.c b/OpenSSL/crypto/x509ext.c index 87fbcc3..81d84dd 100644 --- a/OpenSSL/crypto/x509ext.c +++ b/OpenSSL/crypto/x509ext.c @@ -1,12 +1,12 @@ /* * x509ext.c * - * Copyright (C) Jean-Paul Calderone 2008, All rights reserved + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * Export X.509 extension functions and data structures. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: x509ext.c,v 1.1 2002/07/09 13:34:46 martin Exp $ */ #include <Python.h> @@ -51,6 +51,26 @@ crypto_X509Extension_get_short_name(crypto_X509ExtensionObj *self, PyObject *arg } +static char crypto_X509Extension_get_data_doc[] = "\n\ +Returns the data of the X509Extension\n\ +\n\ +@return: A C{str} giving the X509Extension's ASN.1 encoded data.\n\ +"; + +static PyObject * +crypto_X509Extension_get_data(crypto_X509ExtensionObj *self, PyObject *args) { + ASN1_OCTET_STRING *data; + PyObject *result; + + if (!PyArg_ParseTuple(args, ":get_data")) { + return NULL; + } + + data = X509_EXTENSION_get_data(self->x509_extension); + result = PyBytes_FromStringAndSize((const char*)data->data, data->length); + return result; +} + /* * ADD_METHOD(name) expands to a correct PyMethodDef declaration * { 'name', (PyCFunction)crypto_X509Extension_name, METH_VARARGS } @@ -62,6 +82,7 @@ static PyMethodDef crypto_X509Extension_methods[] = { ADD_METHOD(get_critical), ADD_METHOD(get_short_name), + ADD_METHOD(get_data), { NULL, NULL } }; #undef ADD_METHOD diff --git a/OpenSSL/crypto/x509ext.h b/OpenSSL/crypto/x509ext.h index 6ce7f68..3ddc716 100644 --- a/OpenSSL/crypto/x509ext.h +++ b/OpenSSL/crypto/x509ext.h @@ -1,12 +1,12 @@ /* * x509ext.h * - * Copyright (C) Awanim 2002, All rights reserved + * Copyright (C) Awanim + * See LICENSE for details. * * Export X.509 extension functions and data structures. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: x509ext.h,v 1.2 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_crypto_X509EXTENSION_H_ #define PyOpenSSL_crypto_X509EXTENSION_H_ diff --git a/OpenSSL/crypto/x509name.c b/OpenSSL/crypto/x509name.c index ed3302d..422314d 100644 --- a/OpenSSL/crypto/x509name.c +++ b/OpenSSL/crypto/x509name.c @@ -1,8 +1,9 @@ /* * x509name.c * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008-2009, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * X.509 Name handling, mostly thin wrapping. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/x509name.h b/OpenSSL/crypto/x509name.h index 362ce35..bfc7628 100644 --- a/OpenSSL/crypto/x509name.h +++ b/OpenSSL/crypto/x509name.h @@ -1,14 +1,14 @@ /* * x509name.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export X.509 name functions and data structures. * See the file RATIONALE for a short explanation of why this module was written. * * Reviewed 2001-07-23 * - * @(#) $Id: x509name.h,v 1.8 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_crypto_X509NAME_H_ #define PyOpenSSL_crypto_X509NAME_H_ diff --git a/OpenSSL/crypto/x509req.c b/OpenSSL/crypto/x509req.c index 74e48b9..7489b65 100644 --- a/OpenSSL/crypto/x509req.c +++ b/OpenSSL/crypto/x509req.c @@ -1,8 +1,9 @@ /* * x509req.c * - * Copyright (C) AB Strakt 2001, All rights reserved - * Copyright (C) Jean-Paul Calderone 2008, All rights reserved + * Copyright (C) AB Strakt + * Copyright (C) Jean-Paul Calderone + * See LICENSE for details. * * X.509 Request handling, mostly thin wrapping. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/x509req.h b/OpenSSL/crypto/x509req.h index db8043c..5fe0524 100644 --- a/OpenSSL/crypto/x509req.h +++ b/OpenSSL/crypto/x509req.h @@ -1,12 +1,12 @@ /* * x509req.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export X509 request functions and data structures. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: x509req.h,v 1.6 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_SSL_X509REQ_H_ #define PyOpenSSL_SSL_X509REQ_H_ diff --git a/OpenSSL/crypto/x509store.c b/OpenSSL/crypto/x509store.c index 30ae508..c6fa10c 100644 --- a/OpenSSL/crypto/x509store.c +++ b/OpenSSL/crypto/x509store.c @@ -1,7 +1,8 @@ /* * x509store.c * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * X.509 Store handling, mostly thin wrapping. * See the file RATIONALE for a short explanation of why this module was written. diff --git a/OpenSSL/crypto/x509store.h b/OpenSSL/crypto/x509store.h index 9ed5073..de3531d 100644 --- a/OpenSSL/crypto/x509store.h +++ b/OpenSSL/crypto/x509store.h @@ -1,12 +1,12 @@ /* * x509store.h * - * Copyright (C) AB Strakt 2001, All rights reserved + * Copyright (C) AB Strakt + * See LICENSE for details. * * Export X509 store functions and data structures. * See the file RATIONALE for a short explanation of why this module was written. * - * @(#) $Id: x509store.h,v 1.4 2002/09/04 22:24:59 iko Exp $ */ #ifndef PyOpenSSL_SSL_X509STORE_H_ #define PyOpenSSL_SSL_X509STORE_H_ |