152
static char ssl_Session_from_asn1_doc[] = "\n\
153
Deserialize a Session object from an ASN.1 string.\n\
155
:returns: A :py:class:`Session` instance representing the session from the\n\
159
ssl_Session_from_asn1(PyObject *cls, PyObject *args) {
160
SSL_SESSION *native_session;
163
const unsigned char **asn1p = (const unsigned char**)&asn1;
166
if (!PyArg_ParseTuple(args, "s#:from_asn1", asn1p, &length)) {
170
native_session = d2i_SSL_SESSION(NULL, asn1p, length);
171
if (native_session == NULL) {
172
exception_from_error_queue(ssl_Error);
176
/* XXX Not respecting subclassing here.
178
return (PyObject *)ssl_Session_from_SSL_SESSION(native_session);
181
static char ssl_Session_to_asn1_doc[] = "\n\
182
Serialize the Session object to an ASN.1 representation of it.\n\
184
:returns: A :py:obj:`str` containing the ASN.1 representation.\n\
187
ssl_Session_to_asn1(ssl_SessionObj *self, PyObject *args) {
188
unsigned char *buffer, *p;
192
if (!PyArg_ParseTuple(args, ":to_asn1")) {
196
size = i2d_SSL_SESSION(self->session, NULL);
198
PyErr_SetString(PyExc_ValueError, "Invalid session.");
202
buffer = (unsigned char*)PyMem_Malloc(sizeof(unsigned char) * size);
204
i2d_SSL_SESSION(self->session, &p);
205
ret = PyBytes_FromStringAndSize((const char *)buffer, size);
153
212
* Member methods in the Session object
154
213
* ADD_METHOD(name) expands to a correct PyMethodDef declaration