blob: 4ff2c34c083fcb16d0fb479ae15f088716f3ad75 [file] [log] [blame]
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05001/*
2 * x509name.c
3 *
Jean-Paul Calderone8671c852011-03-02 19:26:20 -05004 * Copyright (C) AB Strakt
5 * Copyright (C) Jean-Paul Calderone
6 * See LICENSE for details.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05007 *
8 * X.509 Name handling, mostly thin wrapping.
9 * See the file RATIONALE for a short explanation of why this module was written.
10 *
11 * Reviewed 2001-07-23
12 */
13#include <Python.h>
14#define crypto_MODULE
15#include "crypto.h"
16
Jean-Paul Calderone28ebb302008-12-29 16:25:30 -050017static PyMethodDef crypto_X509Name_methods[4];
Jean-Paul Calderone110cd092008-03-24 17:27:42 -040018
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050019/*
20 * Constructor for X509Name, never called by Python code directly
21 *
22 * Arguments: name - A "real" X509_NAME object
23 * dealloc - Boolean value to specify whether the destructor should
24 * free the "real" X509_NAME object
25 * Returns: The newly created X509Name object
26 */
27crypto_X509NameObj *
28crypto_X509Name_New(X509_NAME *name, int dealloc)
29{
30 crypto_X509NameObj *self;
31
32 self = PyObject_GC_New(crypto_X509NameObj, &crypto_X509Name_Type);
33
34 if (self == NULL)
35 return NULL;
36
37 self->x509_name = name;
38 self->dealloc = dealloc;
39 self->parent_cert = NULL;
40
41 PyObject_GC_Track(self);
42 return self;
43}
44
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -040045
46static char crypto_X509Name_doc[] = "\n\
47X509Name(name) -> New X509Name object\n\
48\n\
49Create a new X509Name, copying the given X509Name instance.\n\
50\n\
51@param name: An X509Name object to copy\n\
52@return: The X509Name object\n\
53";
54
55static PyObject *
56crypto_X509Name_new(PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
57{
58 crypto_X509NameObj *name;
59
60 if (!PyArg_ParseTuple(args, "O!:X509Name", &crypto_X509Name_Type, &name)) {
61 return NULL;
62 }
63
64 return (PyObject *)crypto_X509Name_New(X509_NAME_dup(name->x509_name), 1);
65}
66
67
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050068/*
69 * Return a name string given a X509_NAME object and a name identifier. Used
70 * by the getattr function.
71 *
72 * Arguments: name - The X509_NAME object
73 * nid - The name identifier
74 * Returns: The name as a Python string object
75 */
76static int
77get_name_by_nid(X509_NAME *name, int nid, char **utf8string)
78{
79 int entry_idx;
80 X509_NAME_ENTRY *entry;
81 ASN1_STRING *data;
82 int len;
83
84 if ((entry_idx = X509_NAME_get_index_by_NID(name, nid, -1)) == -1)
85 {
86 return 0;
87 }
88 entry = X509_NAME_get_entry(name, entry_idx);
89 data = X509_NAME_ENTRY_get_data(entry);
90 if ((len = ASN1_STRING_to_UTF8((unsigned char **)utf8string, data)) < 0)
91 {
Rick Deand369c932009-07-08 11:48:33 -050092 exception_from_error_queue(crypto_Error);
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050093 return -1;
94 }
95
96 return len;
97}
98
99/*
100 * Given a X509_NAME object and a name identifier, set the corresponding
101 * attribute to the given string. Used by the setattr function.
102 *
103 * Arguments: name - The X509_NAME object
104 * nid - The name identifier
105 * value - The string to set
106 * Returns: 0 for success, -1 on failure
107 */
108static int
109set_name_by_nid(X509_NAME *name, int nid, char *utf8string)
110{
111 X509_NAME_ENTRY *ne;
112 int i, entry_count, temp_nid;
113
114 /* If there's an old entry for this NID, remove it */
115 entry_count = X509_NAME_entry_count(name);
116 for (i = 0; i < entry_count; i++)
117 {
118 ne = X509_NAME_get_entry(name, i);
119 temp_nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(ne));
120 if (temp_nid == nid)
121 {
122 ne = X509_NAME_delete_entry(name, i);
123 X509_NAME_ENTRY_free(ne);
124 break;
125 }
126 }
127
128 /* Add the new entry */
Jean-Paul Calderone28ebb302008-12-29 16:25:30 -0500129 if (!X509_NAME_add_entry_by_NID(name, nid, MBSTRING_UTF8,
130 (unsigned char *)utf8string,
131 -1, -1, 0))
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500132 {
Rick Deand369c932009-07-08 11:48:33 -0500133 exception_from_error_queue(crypto_Error);
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500134 return -1;
135 }
136 return 0;
137}
138
139
140/*
141 * Find attribute. An X509Name object has the following attributes:
142 * countryName (alias C), stateOrProvince (alias ST), locality (alias L),
143 * organization (alias O), organizationalUnit (alias OU), commonName (alias
144 * CN) and more...
145 *
146 * Arguments: self - The X509Name object
147 * name - The attribute name
148 * Returns: A Python object for the attribute, or NULL if something went
149 * wrong
150 */
151static PyObject *
Jean-Paul Calderone0f31ec52010-08-11 22:56:42 -0400152crypto_X509Name_getattro(crypto_X509NameObj *self, PyObject *nameobj)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500153{
154 int nid, len;
155 char *utf8string;
Jean-Paul Calderone3fe7f672010-08-11 23:55:10 -0400156 char *name;
157#ifdef PY3
Jean-Paul Calderonedc3275f2010-08-22 17:04:09 -0400158 name = PyBytes_AsString(PyUnicode_AsASCIIString(nameobj));
159#else
Jean-Paul Calderone3fe7f672010-08-11 23:55:10 -0400160 name = PyBytes_AsString(nameobj);
Jean-Paul Calderonedc3275f2010-08-22 17:04:09 -0400161#endif
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500162
Jean-Paul Calderoneef414d52009-07-16 16:21:04 -0400163 if ((nid = OBJ_txt2nid(name)) == NID_undef) {
164 /*
165 * This is a bit weird. OBJ_txt2nid indicated failure, but it seems
166 * a lower level function, a2d_ASN1_OBJECT, also feels the need to
167 * push something onto the error queue. If we don't clean that up
168 * now, someone else will bump into it later and be quite confused.
169 * See lp#314814.
170 */
171 flush_error_queue();
Jean-Paul Calderone0f31ec52010-08-11 22:56:42 -0400172 return PyObject_GenericGetAttr((PyObject*)self, nameobj);
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500173 }
174
175 len = get_name_by_nid(self->x509_name, nid, &utf8string);
176 if (len < 0)
177 return NULL;
178 else if (len == 0)
179 {
180 Py_INCREF(Py_None);
181 return Py_None;
182 }
Jean-Paul Calderone5b8c5ee2008-02-19 00:43:02 -0500183 else {
184 PyObject* result = PyUnicode_Decode(utf8string, len, "utf-8", NULL);
185 OPENSSL_free(utf8string);
186 return result;
187 }
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500188}
189
190/*
191 * Set attribute
192 *
193 * Arguments: self - The X509Name object
194 * name - The attribute name
195 * value - The value to set
196 */
197static int
Jean-Paul Calderone9ce9afb2011-04-22 18:16:22 -0400198crypto_X509Name_setattro(crypto_X509NameObj *self, PyObject *nameobj, PyObject *value)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500199{
200 int nid;
Jean-Paul Calderone7b0443a2008-02-19 00:25:30 -0500201 int result;
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500202 char *buffer;
Jean-Paul Calderone9ce9afb2011-04-22 18:16:22 -0400203 char *name;
204
205 if (!PyString_CheckExact(nameobj) || !(name = PyString_AsString(nameobj))) {
206 PyErr_Format(PyExc_TypeError,
207 "attribute name must be string, not '%.200s'",
208 Py_TYPE(nameobj)->tp_name);
209 return -1;
210 }
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500211
212 if ((nid = OBJ_txt2nid(name)) == NID_undef)
213 {
Jean-Paul Calderone9ce9afb2011-04-22 18:16:22 -0400214 /* Just like the case in the getattr function */
215 flush_error_queue();
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500216 PyErr_SetString(PyExc_AttributeError, "No such attribute");
217 return -1;
218 }
219
220 /* Something of a hack to get nice unicode behaviour */
221 if (!PyArg_Parse(value, "es:setattr", "utf-8", &buffer))
222 return -1;
Jean-Paul Calderone5b8c5ee2008-02-19 00:43:02 -0500223
Jean-Paul Calderone7b0443a2008-02-19 00:25:30 -0500224 result = set_name_by_nid(self->x509_name, nid, buffer);
225 PyMem_Free(buffer);
226 return result;
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500227}
228
229/*
230 * Compare two X509Name structures.
231 *
232 * Arguments: n - The first X509Name
233 * m - The second X509Name
234 * Returns: <0 if n < m, 0 if n == m and >0 if n > m
235 */
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400236static PyObject *
237crypto_X509Name_richcompare(PyObject *n, PyObject *m, int op) {
238 int result;
239
240 if (!crypto_X509Name_Check(n) || !crypto_X509Name_Check(m)) {
241 Py_INCREF(Py_NotImplemented);
242 return Py_NotImplemented;
243 }
244
245 result = X509_NAME_cmp(
246 ((crypto_X509NameObj*)n)->x509_name,
247 ((crypto_X509NameObj*)m)->x509_name);
248
249 switch (op) {
250 case Py_EQ:
251 result = (result == 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400252 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400253
254 case Py_NE:
255 result = (result != 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400256 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400257
258 case Py_LT:
259 result = (result < 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400260 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400261
262 case Py_LE:
263 result = (result <= 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400264 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400265
266 case Py_GT:
267 result = (result > 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400268 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400269
270 case Py_GE:
271 result = (result >= 0);
Jean-Paul Calderone072195d2010-08-12 20:09:57 -0400272 break;
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400273
274 default:
275 /* Should be impossible */
276 Py_INCREF(Py_NotImplemented);
277 return Py_NotImplemented;
278 }
279
280 if (result) {
281 Py_INCREF(Py_True);
282 return Py_True;
Jean-Paul Calderone138a3122008-12-30 15:05:38 -0500283 } else {
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400284 Py_INCREF(Py_False);
285 return Py_False;
Jean-Paul Calderone138a3122008-12-30 15:05:38 -0500286 }
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500287}
288
289/*
290 * String representation of an X509Name
291 *
292 * Arguments: self - The X509Name object
293 * Returns: A string representation of the object
294 */
295static PyObject *
296crypto_X509Name_repr(crypto_X509NameObj *self)
297{
298 char tmpbuf[512] = "";
299 char realbuf[512+64];
300
301 if (X509_NAME_oneline(self->x509_name, tmpbuf, 512) == NULL)
302 {
Rick Deand369c932009-07-08 11:48:33 -0500303 exception_from_error_queue(crypto_Error);
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500304 return NULL;
305 }
306 else
307 {
308 /* This is safe because tmpbuf is max 512 characters */
309 sprintf(realbuf, "<X509Name object '%s'>", tmpbuf);
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400310 return PyText_FromString(realbuf);
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500311 }
312}
313
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400314static char crypto_X509Name_hash_doc[] = "\n\
Jean-Paul Calderone54bcc832009-05-27 14:06:48 -0400315Return the hash value of this name\n\
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400316\n\
Jean-Paul Calderone54bcc832009-05-27 14:06:48 -0400317@return: None\n\
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400318";
319
320/*
321 * First four bytes of the MD5 digest of the DER form of an X509Name.
322 *
323 * Arguments: self - The X509Name object
324 * Returns: An integer giving the hash.
325 */
326static PyObject *
327crypto_X509Name_hash(crypto_X509NameObj *self, PyObject* args)
328{
329 unsigned long hash;
330
331 if (!PyArg_ParseTuple(args, ":hash")) {
332 return NULL;
333 }
334 hash = X509_NAME_hash(self->x509_name);
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400335 return PyLong_FromLong(hash);
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400336}
337
Jean-Paul Calderonee957a002008-03-25 15:16:51 -0400338static char crypto_X509Name_der_doc[] = "\n\
Jean-Paul Calderone54bcc832009-05-27 14:06:48 -0400339Return the DER encoding of this name\n\
Jean-Paul Calderonee957a002008-03-25 15:16:51 -0400340\n\
Jean-Paul Calderone54bcc832009-05-27 14:06:48 -0400341@return: None\n\
Jean-Paul Calderonee957a002008-03-25 15:16:51 -0400342";
343
344/*
345 * Arguments: self - The X509Name object
346 * Returns: The DER form of an X509Name.
347 */
348static PyObject *
349crypto_X509Name_der(crypto_X509NameObj *self, PyObject *args)
350{
351 if (!PyArg_ParseTuple(args, ":der")) {
352 return NULL;
353 }
354
355 i2d_X509_NAME(self->x509_name, 0);
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400356 return PyBytes_FromStringAndSize(self->x509_name->bytes->data,
357 self->x509_name->bytes->length);
Jean-Paul Calderonee957a002008-03-25 15:16:51 -0400358}
359
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400360
Jean-Paul Calderonec54cc182008-03-26 21:11:07 -0400361static char crypto_X509Name_get_components_doc[] = "\n\
362Returns the split-up components of this name.\n\
363\n\
Jean-Paul Calderone54bcc832009-05-27 14:06:48 -0400364@return: List of tuples (name, value).\n\
Jean-Paul Calderonec54cc182008-03-26 21:11:07 -0400365";
366
367static PyObject *
368crypto_X509Name_get_components(crypto_X509NameObj *self, PyObject *args)
369{
370 int n, i;
371 X509_NAME *name = self->x509_name;
372 PyObject *list;
373
374 if (!PyArg_ParseTuple(args, ":get_components"))
375 return NULL;
376
377 n = X509_NAME_entry_count(name);
378 list = PyList_New(n);
379 for (i = 0; i < n; i++)
380 {
381 X509_NAME_ENTRY *ent;
382 ASN1_OBJECT *fname;
383 ASN1_STRING *fval;
384 int nid;
385 int l;
Jean-Paul Calderonec54cc182008-03-26 21:11:07 -0400386 unsigned char *str;
387 PyObject *tuple;
388
389 ent = X509_NAME_get_entry(name, i);
390
391 fname = X509_NAME_ENTRY_get_object(ent);
392 fval = X509_NAME_ENTRY_get_data(ent);
393
394 l = ASN1_STRING_length(fval);
395 str = ASN1_STRING_data(fval);
396
397 nid = OBJ_obj2nid(fname);
398
399 /* printf("fname is %s len=%d str=%s\n", OBJ_nid2sn(nid), l, str); */
400
401 tuple = PyTuple_New(2);
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400402 PyTuple_SetItem(tuple, 0, PyBytes_FromString(OBJ_nid2sn(nid)));
403 PyTuple_SetItem(tuple, 1, PyBytes_FromStringAndSize((char *)str, l));
Jean-Paul Calderonec54cc182008-03-26 21:11:07 -0400404
405 PyList_SetItem(list, i, tuple);
406 }
407
408 return list;
409}
410
411
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500412/*
413 * Call the visitproc on all contained objects.
414 *
415 * Arguments: self - The Connection object
416 * visit - Function to call
417 * arg - Extra argument to visit
418 * Returns: 0 if all goes well, otherwise the return code from the first
419 * call that gave non-zero result.
420 */
421static int
422crypto_X509Name_traverse(crypto_X509NameObj *self, visitproc visit, void *arg)
423{
424 int ret = 0;
425
426 if (ret == 0 && self->parent_cert != NULL)
427 ret = visit(self->parent_cert, arg);
428 return ret;
429}
430
431/*
432 * Decref all contained objects and zero the pointers.
433 *
434 * Arguments: self - The Connection object
435 * Returns: Always 0.
436 */
437static int
438crypto_X509Name_clear(crypto_X509NameObj *self)
439{
440 Py_XDECREF(self->parent_cert);
441 self->parent_cert = NULL;
442 return 0;
443}
444
445/*
446 * Deallocate the memory used by the X509Name object
447 *
448 * Arguments: self - The X509Name object
449 * Returns: None
450 */
451static void
452crypto_X509Name_dealloc(crypto_X509NameObj *self)
453{
454 PyObject_GC_UnTrack(self);
455 /* Sometimes we don't have to dealloc this */
456 if (self->dealloc)
457 X509_NAME_free(self->x509_name);
458
459 crypto_X509Name_clear(self);
460
461 PyObject_GC_Del(self);
462}
463
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400464/*
465 * ADD_METHOD(name) expands to a correct PyMethodDef declaration
466 * { 'name', (PyCFunction)crypto_X509_name, METH_VARARGS }
467 * for convenience
468 */
469#define ADD_METHOD(name) \
470 { #name, (PyCFunction)crypto_X509Name_##name, METH_VARARGS, crypto_X509Name_##name##_doc }
471static PyMethodDef crypto_X509Name_methods[] =
472{
473 ADD_METHOD(hash),
Jean-Paul Calderonee957a002008-03-25 15:16:51 -0400474 ADD_METHOD(der),
Jean-Paul Calderonec54cc182008-03-26 21:11:07 -0400475 ADD_METHOD(get_components),
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400476 { NULL, NULL }
477};
478#undef ADD_METHOD
479
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500480PyTypeObject crypto_X509Name_Type = {
Jean-Paul Calderone3fe7f672010-08-11 23:55:10 -0400481 PyOpenSSL_HEAD_INIT(&PyType_Type, 0)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500482 "X509Name",
483 sizeof(crypto_X509NameObj),
484 0,
485 (destructor)crypto_X509Name_dealloc,
486 NULL, /* print */
Jean-Paul Calderone0f31ec52010-08-11 22:56:42 -0400487 NULL, /* getattr */
Jean-Paul Calderone9ce9afb2011-04-22 18:16:22 -0400488 NULL, /* setattr */
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400489 NULL, /* reserved */
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500490 (reprfunc)crypto_X509Name_repr,
491 NULL, /* as_number */
492 NULL, /* as_sequence */
493 NULL, /* as_mapping */
494 NULL, /* hash */
495 NULL, /* call */
496 NULL, /* str */
Jean-Paul Calderone0f31ec52010-08-11 22:56:42 -0400497 (getattrofunc)crypto_X509Name_getattro, /* getattro */
Jean-Paul Calderone9ce9afb2011-04-22 18:16:22 -0400498 (setattrofunc)crypto_X509Name_setattro, /* setattro */
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500499 NULL, /* as_buffer */
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400500 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400501 crypto_X509Name_doc, /* tp_doc */
Jean-Paul Calderone110cd092008-03-24 17:27:42 -0400502 (traverseproc)crypto_X509Name_traverse, /* tp_traverse */
503 (inquiry)crypto_X509Name_clear, /* tp_clear */
Jean-Paul Calderone4d0c3212010-08-10 22:57:42 -0400504 crypto_X509Name_richcompare, /* tp_richcompare */
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400505 0, /* tp_weaklistoffset */
506 NULL, /* tp_iter */
507 NULL, /* tp_iternext */
508 crypto_X509Name_methods, /* tp_methods */
509 NULL, /* tp_members */
510 NULL, /* tp_getset */
511 NULL, /* tp_base */
512 NULL, /* tp_dict */
513 NULL, /* tp_descr_get */
514 NULL, /* tp_descr_set */
515 0, /* tp_dictoffset */
516 NULL, /* tp_init */
517 NULL, /* tp_alloc */
518 crypto_X509Name_new, /* tp_new */
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500519};
520
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500521/*
522 * Initialize the X509Name part of the crypto module
523 *
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400524 * Arguments: module - The crypto module
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500525 * Returns: None
526 */
527int
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400528init_crypto_x509name(PyObject *module)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500529{
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400530 if (PyType_Ready(&crypto_X509Name_Type) < 0) {
531 return 0;
532 }
533
Jean-Paul Calderone86ad7112010-05-11 16:08:45 -0400534 /* PyModule_AddObject steals a reference.
535 */
536 Py_INCREF((PyObject *)&crypto_X509Name_Type);
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400537 if (PyModule_AddObject(module, "X509Name", (PyObject *)&crypto_X509Name_Type) != 0) {
538 return 0;
539 }
540
Jean-Paul Calderoneaed23582011-03-12 22:45:02 -0500541 /* PyModule_AddObject steals a reference.
542 */
Jean-Paul Calderoned07d57d2011-03-12 22:35:24 -0500543 Py_INCREF((PyObject *)&crypto_X509Name_Type);
Jean-Paul Calderone2cd7a922009-06-27 11:02:46 -0400544 if (PyModule_AddObject(module, "X509NameType", (PyObject *)&crypto_X509Name_Type) != 0) {
545 return 0;
546 }
547
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500548 return 1;
549}