tleonhardt / practical_cryptography_engineering Goto Github PK
View Code? Open in Web Editor NEWCryptography code examples using libsodium and mbedtls C libraries and Python cryptography and PyNaCl modules
License: Apache License 2.0
Cryptography code examples using libsodium and mbedtls C libraries and Python cryptography and PyNaCl modules
License: Apache License 2.0
In the file nacl_encrypt_file.c
you have the following code:
ret = crypto_secretbox_easy(ciphertext, message, message_len, nonce, key);
if ( ret != 0)
{ // The only way I can see for this function to fail is if the message length is too large (> 2^64 - 16)
printf(" failed. Message length = %lld\n", message_len);
}
However, this only works to encrypt a file, if, and only if, it fits in the computer memory inside the variable messsage
. Take a look at the explanation in the Quick start page of Libsodium. So, with crypto_secretbox_easy
the limit is not 2^64 - 16, but the memory size of message
.
The best way to encrypt a file, regardless of its size, is with crypto_secretstream*
functions (see the file encryption code example on Libsodium docs).
I'm getting the below error code
mbedtls_gcm_setkey failed to set the key for AES cipher - returned -0x61 (MBEDTLS_ERR_CIPHER_ALLOC_FAILED)
In my project, I'm calling mbedtls_gcm_setkey, passed initialized gcm context which calls "mbedtls_cipher_setup"
Inside the "mbedtls_cipher_setup " API...
if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) )
return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED );
It fails here, I don't see ctx_alloc_func references in the repo, am i missing something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.