diff options
author | Jean-Paul Calderone <exarkun@divmod.com> | 2011-04-01 18:27:45 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@divmod.com> | 2011-04-01 18:27:45 -0400 |
commit | 5a9e4618cb0453c64f60436f03c04512a6177481 (patch) | |
tree | da6ac93a10454a19ead01c5833a53c39e010ce62 /OpenSSL/crypto | |
parent | ea9c8a30558f7a3587f6803f3987fc83a8d8f77b (diff) | |
download | pyopenssl-5a9e4618cb0453c64f60436f03c04512a6177481.tar.gz |
Expose the data in the extension, and tests.
Diffstat (limited to 'OpenSSL/crypto')
-rw-r--r-- | OpenSSL/crypto/x509ext.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/OpenSSL/crypto/x509ext.c b/OpenSSL/crypto/x509ext.c index a874204..75c3311 100644 --- a/OpenSSL/crypto/x509ext.c +++ b/OpenSSL/crypto/x509ext.c @@ -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 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 |