aboutsummaryrefslogtreecommitdiffstats
path: root/misc/python/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-08-22 23:49:56 +0000
committerlloyd <[email protected]>2006-08-22 23:49:56 +0000
commit04ecd7cb4fb7751bb6d466fc8140280fe655040d (patch)
tree4b565a2f00884069c51e699cda929f2c5c2470d6 /misc/python/src
parent8dfd76eb99fd1c8a29096fe594c20b288edc8ac2 (diff)
Add accessors for the key identifiers, and implement equality operators
Diffstat (limited to 'misc/python/src')
-rw-r--r--misc/python/src/x509.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/misc/python/src/x509.cpp b/misc/python/src/x509.cpp
index d2fb3c5e1..f787949de 100644
--- a/misc/python/src/x509.cpp
+++ b/misc/python/src/x509.cpp
@@ -4,6 +4,8 @@
*************************************************/
#include <botan/oids.h>
+#include <botan/pipe.h>
+#include <botan/filters.h>
#include <botan/x509_key.h>
#include <botan/x509cert.h>
using namespace Botan;
@@ -20,14 +22,31 @@ python::list vector_to_list(const C& in)
return out;
}
+python::str hex_encode(const MemoryRegion<byte>& in)
+ {
+ Pipe pipe(new Hex_Encoder);
+ pipe.process_msg(in);
+ return python::str(pipe.read_all_as_string());
+ }
+
+python::str get_auth_keyid(const X509_Certificate* cert)
+ {
+ return hex_encode(cert->authority_key_id());
+ }
+
+python::str get_subject_keyid(const X509_Certificate* cert)
+ {
+ return hex_encode(cert->subject_key_id());
+ }
+
python::list get_subject_info(const X509_Certificate* cert,
- const std::string& type)
+ const std::string& type)
{
return vector_to_list(cert->subject_info(type));
}
python::list get_issuer_info(const X509_Certificate* cert,
- const std::string& type)
+ const std::string& type)
{
return vector_to_list(cert->issuer_info(type));
}
@@ -46,6 +65,8 @@ void export_x509()
{
python::class_<X509_Certificate>
("X509_Certificate", python::init<std::string>())
+ .def(python::self == python::self)
+ .def(python::self != python::self)
.add_property("version", &X509_Certificate::x509_version)
.add_property("is_CA", &X509_Certificate::is_CA_cert)
.add_property("self_signed", &X509_Certificate::is_self_signed)
@@ -55,5 +76,7 @@ void export_x509()
.def("subject_info", get_subject_info)
.def("issuer_info", get_issuer_info)
.def("ex_constraints", get_ex_constraints)
- .def("policies", get_policies);
+ .def("policies", get_policies)
+ .def("subject_key_id", get_subject_keyid)
+ .def("authority_key_id", get_auth_keyid);
}