Commit Graph

130 Commits (565d1b33e5c9a52a0c2752f5ea80f6ca29b08cd1)

Author SHA1 Message Date
Erik Bray a094a36fa8 Update random.py
Realized that `ffi.string()` could truncate the output on null bytes.
2017-01-28 15:55:42 +01:00
Erik Bray e96a720f04 Fixes a serious bug in Random.byte
Python's bytecode compiler has a peephole optimizer which, among other things, can recognize constant expressions and replace them with a constant.

In `Random.byte` the expression `t2b('\0')` is recognized as a constant and is replaced with a single constant compiled into the function's bytecode.

This means that every time you run `Random.byte`, rather than creating a new `str` object (or `bytes` in Python 3) it's reusing the same one each time, and `wc_RNG_GenerateByte` is writing right into that constant object's buffer; hence the following behavior:

```
In [55]: rng = Random()

In [56]: a = rng.byte()

In [57]: a
Out[57]: "'"

In [58]: rng.byte()
Out[58]: '\x11'

In [59]: a
Out[59]: '\x11'

In [60]: rng.byte()
Out[60]: '\x16'

In [61]: a
Out[61]: '\x16'

In [62]: rng.byte.__func__.__code__.co_consts
Out[62]:
('\n        Generate and return a random byte.\n        ',
 '\x16',
 0,
 'RNG generate byte error (%d)')

In [63]: rng.byte()
Out[63]: '\xad'

In [64]: rng.byte.__func__.__code__.co_consts
Out[64]:
('\n        Generate and return a random byte.\n        ',
 '\xad',
 0,
 'RNG generate byte error (%d)')
```

`Random.bytes` does not necessarily have this problem since its result buffer is not a constant expression, though I feel like it could also in principle be affected if the string were interned (though I couldn't produce such a result). Nevertheless, it doesn't seem like a good idea to be updating `str` objects' buffers directly.
2017-01-26 20:48:15 +01:00
Moisés Guimarães d3d7446a24 removes 3DES from docs 2017-01-21 15:31:26 -02:00
Moisés Guimarães a761a7fc64 updates provisioners 2017-01-18 19:19:03 -02:00
Moisés Guimarães feb6617dc9 updates centos provisioner 2017-01-18 18:41:15 -02:00
Moisés Guimarães 51bf46288b adds client example 2017-01-18 18:18:19 -02:00
Moisés Guimarães 5c8e69eb5e updates vagrant configs; updates server example, updates copyright year. 2017-01-18 17:59:48 -02:00
Moisés Guimarães bb97e03a44 initial server tests 2017-01-16 19:40:46 -02:00
Moisés Guimarães 089387906e updates tests 2017-01-16 18:52:34 -02:00
Moisés Guimarães 715d6afeda updates tox config 2017-01-16 18:48:01 -02:00
Moisés Guimarães 0a9f66338c adds coverity tests 2017-01-15 12:51:09 -02:00
Moisés Guimarães 2d56f09320 adds accept() behavior to SSLSocket; Migrates tests to pytest. 2017-01-15 12:26:22 -02:00
Moisés Guimarães 56091e267f moving source code into src 2017-01-12 19:27:36 -02:00
Moisés Guimarães 53d4c171c8 adds more client tests 2016-12-22 17:58:13 -02:00
Moisés Guimarães 35f03eb00a fixes docs. 2016-12-22 16:59:50 -02:00
Moisés Guimarães 1c9147a41e adds supported curves to context; fixes compatibility issues with py27 2016-12-22 15:01:58 -02:00
Moisés Guimarães 9b58ab0211 renames exceptions file 2016-12-22 15:01:58 -02:00
Moisés Guimarães 4b75d11164 fixes socket calls 2016-12-22 15:01:58 -02:00
Moisés Guimarães f3c1522608 always treat native_object as a pointer 2016-12-22 15:01:58 -02:00
Moisés Guimarães b9934695fb pretest version of SSLSocket 2016-12-22 15:01:58 -02:00
Moisés Guimarães 567dfd76b3 adds initial code for SSLSocket 2016-12-22 15:01:58 -02:00
Moisés Guimarães 2cbdd45e8f adds negotiate() to ssl interface 2016-12-22 15:01:58 -02:00
Moisés Guimarães 07072ef266 moving SSLContext and SSLSocket to __init__ to avoid ciclic includes 2016-12-22 15:01:58 -02:00
Moisés Guimarães baeba53527 adds wrap_socket to the context 2016-12-22 15:01:58 -02:00
Moisés Guimarães 445e375daa adds ssl interface to ffi 2016-12-22 15:01:58 -02:00
Moisés Guimarães 52eb0becf0 adds set_ciphers to context 2016-12-22 15:01:58 -02:00
Moisés Guimarães 368f2baf88 adds verify_mode to context 2016-12-22 15:01:58 -02:00
Moisés Guimarães 8eec3cb874 adds initial code for SSLSocket 2016-12-22 15:01:58 -02:00
Moisés Guimarães 0ed0672b16 fixes pylint warnings 2016-12-22 15:01:58 -02:00
Moisés Guimarães c0b59a585b adds support for buffered ca certificates 2016-12-22 15:01:58 -02:00
Moisés Guimarães 015ffecbab fixes unicode quotes and adds load_cert_chain test. 2016-12-22 15:01:58 -02:00
Moisés Guimarães 760ddd14f5 fixes pylint warnings;
adds more tests to load_verify_locations;
fixes data type when calling C functions;
fixes result verification when calling C functions.
2016-12-22 15:01:58 -02:00
Moisés Guimarães 7201435f2d adds initial context tests. 2016-12-22 15:01:58 -02:00
Moisés Guimarães bd14611879 adds load_verify_locations and load_cert_chain implementations. 2016-12-22 15:01:58 -02:00
Moisés Guimarães c8ae6abb43 adds context functions. 2016-12-22 15:01:58 -02:00
Moisés Guimarães e1c01378c7 fixes ssl version in test to maintain backward compatibility. 2016-12-22 15:01:58 -02:00
Moisés Guimarães 20cfbe399c fixes integer comparison and adds virtual env to ignored files. 2016-12-22 15:01:58 -02:00
Moisés Guimarães e06b17e170 adds methods and client tests;
adds context creation;
adds memory module;
removes init and cleanup functions.
2016-12-22 15:01:58 -02:00
Moisés Guimarães 0df897d4b9 adds methods 2016-12-22 15:01:58 -02:00
Moisés Guimarães 7b884ad72a removes non-ASCII chars from docs. 2016-12-22 15:01:58 -02:00
Moisés Guimarães 8b0edafef3 adds build_ffI.py 2016-12-22 15:01:58 -02:00
Moisés Guimarães f4d6890b51 adds basic files and exception classes. 2016-12-22 15:01:58 -02:00
Moisés Guimarães 5f6cf282b1 fixes include.am comments 2016-11-07 21:15:23 -03:00
Moisés Guimarães 88df983251 moves include.am into wolfcrypt-py folder 2016-11-07 21:09:08 -03:00
Moisés Guimarães b50914f2c7 Drops 3DES and adds int wc_RsaSetRNG(RsaKey* key, WC_RNG* rng); for RSA blinding 2016-11-07 16:06:35 -03:00
Moisés Guimarães 08f6d23e84 moves wolfcrypt-py implementation to wrapper/python/wolfcrypt 2016-11-07 16:02:41 -03:00
Jacob Barthelmeh 1ed06b53df C# Wrapper : TCP check connection termination 2016-09-28 15:00:30 -06:00
Moisés Guimarães 7f71c526f6 adds python3 support 2016-06-03 10:37:41 -03:00
Moisés Guimarães 6736ffe10e adds links to wolfssl.com 2016-06-02 22:08:57 -03:00
Moisés Guimarães a76291c2e2 adds tox instructions 2016-06-02 21:38:34 -03:00
Moisés Guimarães 07ce928bf3 adds installation testing with vagrant 2016-05-23 21:10:44 -03:00
Moisés Guimarães 04d5ca41df adds --enable-Sha512 to make sure it is always present 2016-05-23 20:33:11 -03:00
Moisés Guimarães fcc0eb7a6a fixes install instructions 2016-05-20 03:55:57 -03:00
Moisés Guimarães 47a1dd8cc4 fixes install steps 2016-05-17 14:15:17 -03:00
Moisés Guimarães a000ee4db3 remove empty dirs 2016-05-16 22:17:09 -03:00
Moisés Guimarães dc080694b4 reorder installation steps 2016-05-16 21:55:31 -03:00
Moisés Guimarães 2851f7d6a1 remove unnecessary dependency 2016-05-16 20:37:42 -03:00
Moisés Guimarães 2a0adc74a0 fixes wrapper path 2016-05-16 20:13:26 -03:00
Moisés Guimarães 347d80e879 removes folders from include.am 2016-05-16 15:49:32 -03:00
Moisés Guimarães 40cf30a13d adds .gitignore to include.am 2016-05-16 15:31:51 -03:00
Moisés Guimarães d76d74d6c5 updates Linux deps on README 2016-05-15 15:08:16 -03:00
Moisés Guimarães 9659505260 updates python docs 2016-05-09 18:46:01 -03:00
Moisés Guimarães 412141198e drops 'import about' requirement 2016-05-09 15:25:18 -03:00
Moisés Guimarães b0c23ceafa fixes about 2016-05-05 12:48:47 -03:00
Moisés Guimarães 9e9fd24d68 updates metadata; drops py26 tests 2016-05-04 21:38:27 -03:00
Moisés Guimarães 3181731404 adds docs 2016-05-03 00:49:56 -03:00
Moisés Guimarães 69ac477976 updates docs template 2016-04-29 16:25:53 -03:00
Moisés Guimarães 1efd1343ee initial docs 2016-04-29 16:13:38 -03:00
Moisés Guimarães 66d41eee36 updates python README 2016-04-28 13:36:41 -03:00
Moisés Guimarães d8309ab624 adds python ignored files 2016-04-28 13:26:59 -03:00
Moisés Guimarães 7e661ab866 importing wolfcrypt-py repo 2016-04-28 13:20:10 -03:00
Jacob Barthelmeh e99a5b0483 prepare for release v3.9.0 2016-03-17 16:02:13 -06:00
David Garske cb3a9cc348 Removed the execute bit on all .c, .h, and .cs files. 2016-02-08 09:45:31 -08:00
Jacob Barthelmeh 5e0fa1de90 utf8 switched to default and added comments 2016-01-08 16:50:49 -07:00
Jacob Barthelmeh ee1a767332 account for null terminator 2016-01-07 17:39:00 -07:00
Jacob Barthelmeh 1600ba7f3d example IO callback and keep memory alive when needed 2015-12-06 14:30:00 -07:00
Jacob Barthelmeh d673a56c83 change line ending of license to match Windows CR LF 2015-12-01 14:49:16 -07:00
Jacob Barthelmeh 7d13fe9017 license heading 2015-11-20 10:19:55 -07:00
Jacob Barthelmeh 39d6992759 logging levels added 2015-11-20 09:59:08 -07:00
Jacob Barthelmeh b9dae51658 C Sharp wrapper 2015-11-19 20:51:32 -07:00