File tree 9 files changed +15
-21
lines changed
9 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ to help you with making an AES key generator for your key.
25
25
#define TAG_BYTES 16
26
26
27
27
int main (void )
28
- {
28
+ {
29
29
mbedtls_ctr_drbg_context ctr_drbg ;
30
30
mbedtls_entropy_context entropy ;
31
31
mbedtls_gcm_context gcm ;
@@ -156,6 +156,5 @@ int main(void)
156
156
// Free the GCM context and underlying cipher sub-context
157
157
mbedtls_gcm_free (& gcm );
158
158
159
- // TODO: Perform any cleanup of mbed TLS resources necessary
160
159
return ret ;
161
160
}
Original file line number Diff line number Diff line change 10
10
Additional means of verifying integrity such as HMAC are not necessary.
11
11
12
12
NOTE: There is a better way to do AES-GCM in Cryptography version 2.0 or newer using the AES-GCM construction which is
13
- composed of the AES block cipher utilizing GCM mode. But Debian 9 comes with Cryptograhpy 1.7.
14
- The way presented here is compatible with both versions .
13
+ composed of the AES block cipher utilizing GCM mode. This version is intended to be compatible with version 1.7
14
+ or newer of the Cryptography module .
15
15
"""
16
16
import os
17
17
Original file line number Diff line number Diff line change 1
1
/*
2
2
* AES-256 file encryption program using Galois Counter Mode (GCM)
3
3
*
4
- * It has been greatly simplified in the interests of readability at the cost of not being cross-platform compatible.
4
+ * It has been greatly simplified in the interests of readability at the cost of not necessarily being cross-platform
5
+ * compatible to ARM platforms. Tis code is intended to work on Windows, macOS, and Linux.
5
6
*/
6
7
#if !defined(MBEDTLS_CONFIG_FILE )
7
8
#include "mbedtls/config.h"
@@ -403,7 +404,6 @@ int main( int argc, char *argv[] )
403
404
// Free the GCM context and underlying cipher sub-context
404
405
mbedtls_gcm_free (& gcm_ctx );
405
406
406
-
407
407
return ( ret );
408
408
409
409
}
Original file line number Diff line number Diff line change 10
10
Additional means of verifying integrity such as HMAC are not necessary.
11
11
12
12
NOTE: There is a better way to do AES-GCM in Cryptography version 2.0 or newer using the AES-GCM construction which is
13
- composed of the AES block cipher utilizing GCM mode. But Debian 9 comes with Cryptograhpy 1.7.
14
- The way presented here is compatible with both versions.
13
+ composed of the AES block cipher utilizing GCM mode. This should be compatible with Cryptograhpy 1.7 or newer.
15
14
16
15
This is intended to be used in conjunction with teh "aesgcm_file.c" example code for demonstrating interoperability
17
16
between Python's Cryptography module and the mbed TLS C library for AES-256 in GCM mode.
Original file line number Diff line number Diff line change 5
5
*
6
6
* Curve25519 is very fast, but only uses 256 bits (128 bits of security) even though it is highly respected as being
7
7
* safe by pretty much everyone. This curve is suitable for an asymmetric ECDH key exchange used to derive a 128-bit
8
- * key for use with a symmetric cipher such as AES-128.Python's Cryptography module doesn't have support for curve25519
8
+ * key for use with a symmetric cipher such as AES-128. Python's Cryptography module doesn't have support for curve25519
9
9
* until version 2.0 and even then it only supports it with a bleeding-edge version of OpenSSL.
10
10
*
11
11
* Elliptic Curve SECP384R1 is a 384-bit NIST curve over a prime field. This is a curve with intermediate performance
@@ -304,7 +304,7 @@ int main( int argc, char *argv[] )
304
304
}
305
305
mbedtls_printf ( " ok\n" );
306
306
307
- // TODO: Use a Key Derivation Function (KDF) to derive a 256-bit AES key from the 521-bit shared secret
307
+ // TODO: Use a Key Derivation Function (KDF) to derive a 256-bit AES key and an IV from the 521-bit shared secret
308
308
309
309
310
310
exit :
Original file line number Diff line number Diff line change 9
9
* v2.0, also published as Internet Engineering Task Force's RFC 2898. It supercedes PBKDF1, which could only produce
10
10
* keys up to 160 bits long.
11
11
*
12
- * There are better KDF functions availble which address weaknesses in PBDKF2, but PBKDF2 is widely available in most
12
+ * There are better KDF functions available which address weaknesses in PBDKF2, but PBKDF2 is widely available in most
13
13
* libraries.
14
14
*
15
15
* PBKDF2 applies a pseudorandom function, such as a hash-based message authentication code (HMAC), to the input
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
2
# coding=utf-8
3
3
"""
4
- This is a simple example of doing an elliptic curve Diffie-Hellman ECDH) key exchange.
5
-
6
- It allows two parties to jointly agree on a shared secret using an insecure channel.
7
-
8
- NOTE: Cryptography version 2.0 in combination with very new versions of OpenSSL support a simpler
9
- interface to use Curve25519 via from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
4
+ This is a simple Key Derivation Function (KDF) example using Python's cryptography module.
10
5
"""
11
6
import sys
12
7
Original file line number Diff line number Diff line change 7
7
* These routines use the XSalsa20 stream cipher for encryption and the Poly1305 MAC for authentication
8
8
* in pre-packaged set of routines for doing authenticated encryption using symmetric keys.
9
9
*
10
- * NOTE: This is NOT an AEAD (Authenticated Encryption with Additional Data) mode because the MAC computation
11
- * is done over the encrypted ciphertext and does not include any additional data.
10
+ * NOTE: While this is an AE (Authenticated Encryption) mode, this is NOT an AEAD (Authenticated Encryption with
11
+ Additional Data) mode because the MAC computation is just done over the encrypted ciphertext and does not include any
12
+ additional data.
12
13
*
13
14
* XSalsa20 is a stream cipher based upon Salsa20 but with a much longer nonce: 192 bits instead of 64 bits.
14
15
*
Original file line number Diff line number Diff line change 1
1
/* Round trip unit test of using libsodium Ed25519 digital signature code along with PyNacl digital signature code
2
2
*
3
- * 0) Uses a hard-coded signing key seed generated by PyNacl to reconstruct signaing and verifying keys in libsodium
3
+ * 0) Uses a hard-coded signing key seed generated by PyNacl to reconstruct signing and verifying keys in libsodium
4
4
* 1) Reconstructs the signing and verifying keys from this in libsodium
5
5
* 2) Signs a test message
6
6
* 3) Verifies the signature of this test message
@@ -86,4 +86,4 @@ int main(int argc, char *argv[])
86
86
}
87
87
88
88
return ret ;
89
- }
89
+ }
You can’t perform that action at this time.
0 commit comments