Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(159913)

Side by Side Diff: Modules/_ssl.c

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« Modules/fcntlmodule.c ('K') | « Modules/socketmodule.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* SSL socket module 1 /* SSL socket module
2 2
3 SSL support based on patches by Brian E Gallew and Laszlo Kovacs. 3 SSL support based on patches by Brian E Gallew and Laszlo Kovacs.
4 Re-worked a bit by Bill Janssen to add server-side support and 4 Re-worked a bit by Bill Janssen to add server-side support and
5 certificate decoding. Chris Stawarz contributed some non-blocking 5 certificate decoding. Chris Stawarz contributed some non-blocking
6 patches. 6 patches.
7 7
8 This module is imported by ssl.py. It should *not* be used 8 This module is imported by ssl.py. It should *not* be used
9 directly. 9 directly.
10 10
(...skipping 3654 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 0, /*tp_init*/ 3665 0, /*tp_init*/
3666 0, /*tp_alloc*/ 3666 0, /*tp_alloc*/
3667 memory_bio_new, /*tp_new*/ 3667 memory_bio_new, /*tp_new*/
3668 }; 3668 };
3669 3669
3670 3670
3671 /* helper routines for seeding the SSL PRNG */ 3671 /* helper routines for seeding the SSL PRNG */
3672 static PyObject * 3672 static PyObject *
3673 PySSL_RAND_add(PyObject *self, PyObject *args) 3673 PySSL_RAND_add(PyObject *self, PyObject *args)
3674 { 3674 {
3675 char *buf; 3675 Py_buffer view;
3676 const char *buf;
3676 Py_ssize_t len, written; 3677 Py_ssize_t len, written;
3677 double entropy; 3678 double entropy;
3678 3679
3679 if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy)) 3680 if (!PyArg_ParseTuple(args, "s*d:RAND_add", &view, &entropy))
3680 return NULL; 3681 return NULL;
3682 buf = (const char *)view.buf;
3683 len = view.len;
3681 do { 3684 do {
3682 written = Py_MIN(len, INT_MAX); 3685 written = Py_MIN(len, INT_MAX);
3683 RAND_add(buf, (int)written, entropy); 3686 RAND_add(buf, (int)written, entropy);
3684 buf += written; 3687 buf += written;
3685 len -= written; 3688 len -= written;
3686 } while (len); 3689 } while (len);
3690 PyBuffer_Release(&view);
3687 Py_INCREF(Py_None); 3691 Py_INCREF(Py_None);
3688 return Py_None; 3692 return Py_None;
3689 } 3693 }
3690 3694
3691 PyDoc_STRVAR(PySSL_RAND_add_doc, 3695 PyDoc_STRVAR(PySSL_RAND_add_doc,
3692 "RAND_add(string, entropy)\n\ 3696 "RAND_add(string, entropy)\n\
3693 \n\ 3697 \n\
3694 Mix string into the OpenSSL PRNG state. entropy (a float) is a lower\n\ 3698 Mix string into the OpenSSL PRNG state. entropy (a float) is a lower\n\
3695 bound on the entropy contained in string. See RFC 1750."); 3699 bound on the entropy contained in string. See RFC 1750.");
3696 3700
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
4652 return NULL; 4656 return NULL;
4653 4657
4654 libver = OPENSSL_VERSION_NUMBER; 4658 libver = OPENSSL_VERSION_NUMBER;
4655 parse_openssl_version(libver, &major, &minor, &fix, &patch, &status); 4659 parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
4656 r = Py_BuildValue("IIIII", major, minor, fix, patch, status); 4660 r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
4657 if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r)) 4661 if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
4658 return NULL; 4662 return NULL;
4659 4663
4660 return m; 4664 return m;
4661 } 4665 }
OLDNEW
« Modules/fcntlmodule.c ('K') | « Modules/socketmodule.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+