Commit Graph

21 Commits (0340b49ff9f10e9b217a8980d8e1b19b2bc68021)

Author SHA1 Message Date
Jacob Barthelmeh c729318ddd update copyright date 2021-03-11 13:42:46 +07:00
Chris Conlon 45c5a2d39c update copyright to 2020 2020-01-03 15:06:03 -08:00
John Safranek 246c444b93 Updates for v4.0.0
Update the copyright dates on all the source files to the current year.
2019-03-15 10:37:36 -07:00
Chris Conlon 667b8431cc Merge pull request #683 from moisesguimaraes/wolfssl-py
wolfssl python wrapper
2017-07-19 09:22:02 -07:00
Chris Conlon 042ee817f3 Merge pull request #757 from moisesguimaraes/updates-wolfcrypt-py-docs
Removes 3DES from the wolfCrypt Python docs
2017-06-13 10:55:21 -06:00
Erik Bray bf12e4ecca wolfcrypt Python: work around minor issue in Random.__del__
During interpreter shutdown, depending on the order in which things happen, a module can be unloaded before all instances of classes defined in that module are garbage collected.

In particular, this means that any global variables (including imported modules) become `None` by the time the instances `__del__` is called, resulting in
```
AttributeError: 'NoneType' object has no attribute 'wc_FreeRng'
```
being displayed while the process exits.  This can be avoided simply by catching and ignoring the `AttributeError` in this case, since the process is shutting down anyways.
2017-02-02 16:51:41 +01:00
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 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 c8ae6abb43 adds context functions. 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
Moisés Guimarães a76291c2e2 adds tox instructions 2016-06-02 21:38:34 -03:00
Moisés Guimarães fcc0eb7a6a fixes install instructions 2016-05-20 03:55:57 -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 3181731404 adds docs 2016-05-03 00:49:56 -03:00
Moisés Guimarães 7e661ab866 importing wolfcrypt-py repo 2016-04-28 13:20:10 -03:00