generating random with crypto
-
I'm having a trouble generating a random using the crypto module.
I'm following the documentation but I stumble upon an error.
I'm working with the latest firmware (1.2.2.b1)>>> import crypto >>> from crypto import AES >>> iv = crypto.getrandbits(128) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'getrandbits'Seems like there's no
getrandbitsmethod on the crypto module. -
@iber, You're totally right. The code for it was merged into master a day after the last release, but with all the restructuring of the documentation, it ended up being published before it was included in a firmware release. I will be available in today's release. Hope you find the addition useful :)
-
great, looking forward to it.
I currently moved on using a 'not so random' value ;) -
@ iber
iv = uos.urandom(16)This should also work right.
-
-
@abilio Good to know.
-
Do you specifically need it?
-
uos.urandomis based on a linear feedback shift register, that is seeded with a number derived from the MAC address. The values will "look" like random for a whole period, but still easily predictable.crypto.getrandbitsis based on a hardware random number generator that gathers it's bits from random events (noise) received by the WiFi and Bluetooth radios. This source, according to the Espressif, passes randomness tests.@obertuckerz112, needed for writing a few AES examples? probably not. Needed for real life applications? The experts in cryptography say that you need a good source (as in unpredictable) of random numbers for things like the initialization vector (IV). Clearly,
uos.urandomis not.In order to allow people to construct the best possible applications, we hence provide access to the hardware random number generator
getrandbitsas an usable source and recommend the people to use it instead ofuos.urandomfor cryptography purposes.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login