Skip to content

Commit 6b26856

Browse files
committed
Fixed spelling errors in comments
Also: - Improved top-level README - Added details on examples present in sodium directory to it's Readme
1 parent 61af174 commit 6b26856

18 files changed

+92
-34
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ This repository contains some practical code examples of using the following cry
1717

1818
File Contents
1919
=============
20+
21+
Build-related and Miscellaneous
22+
-------------------------------
23+
* CMakeLists.txt
24+
* CMake file for building the mbedTLS C code projects
25+
* mbedtls
26+
* Directory containing the mbedTLS C code
27+
* sodium
28+
* Directory containing libsodium examples, headers, and Windows pre-compiled library
29+
* See the Readme.md in this directory for more info on these examples
30+
31+
Symmetric Encryption
32+
--------------------
2033
* aes_gcm.c
2134
* Simple self-contained C code example of using AES-256 in Galois Counter Mode (GCM) using hard-coded everything
2235
* aes_gcm_cryptography.py
@@ -26,24 +39,27 @@ File Contents
2639
* Takes arguments on command line and produces output to file
2740
* aesgcm_file.py
2841
* Python code example of file-based AES-256 GCM, works with aesgcm_file.c
29-
* CMakeLists.txt
30-
* CMake file for building the mbedTLS C code projects
42+
43+
Key Exchange
44+
------------
3145
* ecdh.c
3246
* Elliptic Curve Diffie-Hellman key exchange C code example
3347
* ecdh.py
3448
* Elliptic Curve Diffie-Hellman key exchange Python code example
49+
50+
Key Derivation
51+
--------------
3552
* kdf.c
3653
* Key Derivation Function (KDF) C code example
3754
* kdf.py
3855
* Key Derivation Function (KDF) Python code example
39-
* mbedtls
40-
* Directory containing the mbedTLS C code
56+
57+
Digital Signatures
58+
------------------
4159
* rsa_signature.c
4260
* RSA Signature C code example
4361
* rsa_signature.py
4462
* RSA Signature Python code example
45-
* sodium
46-
* Directory containing libsodium examples, headers, and Windows pre-compiled library
4763

4864

4965
Building

aesgcm_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Additional means of verifying integrity such as HMAC are not necessary.
1111
1212
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. This should be compatible with Cryptograhpy 1.7 or newer.
13+
composed of the AES block cipher utilizing GCM mode. This should be compatible with Cryptography 1.7 or newer.
1414
1515
This is intended to be used in conjunction with teh "aesgcm_file.c" example code for demonstrating interoperability
1616
between Python's Cryptography module and the mbed TLS C library for AES-256 in GCM mode.

kdf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* mbedtls_pkcs5_pbkdf2_hmac() function in the pkcs5.h/.c files.
66
*
77
* PBDKF2 is a KDF with sliding computation cost aimed to reduce the vulnerability of encrypted keys to brute force
8-
* attacks. PBKDF2 is part of RSA Laboratorie's Public-Key Cryptography Standards (PKCS) series, specifically PKCS#5
9-
* v2.0, also published as Internet Engineering Task Force's RFC 2898. It supercedes PBKDF1, which could only produce
8+
* attacks. PBKDF2 is part of RSA Laboratory's Public-Key Cryptography Standards (PKCS) series, specifically PKCS#5
9+
* v2.0, also published as Internet Engineering Task Force's RFC 2898. It supersedes PBKDF1, which could only produce
1010
* keys up to 160 bits long.
1111
*
1212
* There are better KDF functions available which address weaknesses in PBDKF2, but PBKDF2 is widely available in most

nacl_sign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
with open(input_filename, 'rb') as msg_file:
4646
msg = msg_file.read()
4747

48-
# Sign a message with the signing key - this also containes the original message at the end
48+
# Sign a message with the signing key - this also contains the original message at the end
4949
sig = signing_key.sign(msg)
5050

5151
# Save the signature to an output file

rsa_sign.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* - filename.sig - signature is saved to filename.sig where "filename" is the complete input filename
1313
*
1414
* Notes:
15-
* This uses the Probabilisitc Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
15+
* This uses the Probabilistic Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
1616
*/
1717

1818
#if !defined(MBEDTLS_CONFIG_FILE)
@@ -56,7 +56,7 @@ int main( void )
5656

5757

5858
// Set RSA padding scheme, use PKCS_V21 for PKCS#1 v2.1 PSS probabilistic signatures or PKCS_V15 for older PKCS#1 v1.5
59-
// The RSA Probabilisitc Signature Scheme (PSS) should be used since it is more secure.
59+
// The RSA Probabilistic Signature Scheme (PSS) should be used since it is more secure.
6060
// However, some older encryption libraries only support the older deterministic PKCS#1 v.15 scheme
6161
//#define RSA_PADDING MBEDTLS_RSA_PKCS_V21
6262
#define RSA_PADDING MBEDTLS_RSA_PKCS_V15

rsa_sign.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* - filename.sig - signature is saved to filename.sig where "filename" is the complete input filename
1515
*
1616
* Notes:
17-
* This uses the Probabilisitc Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
17+
* This uses the Probabilistic Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
1818
"""
1919
import sys
2020

@@ -69,7 +69,7 @@ def print_usage() -> None:
6969

7070
# Instantiate an instance of AsymmetricPadding to use
7171
if RSA_PADDING == PSS_PADDING:
72-
# PKCS#1 v2.1 probabilistic padding sheme (PSS)
72+
# PKCS#1 v2.1 probabilistic padding scheme (PSS)
7373
padding = padding.PSS(mgf=padding.MGF1(hashes.SHA512()), # A mask generation function object
7474
salt_length=padding.PSS.MAX_LENGTH) # The length of the salt
7575
else:

rsa_verify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* - signature has been saved to filename.sig where "filename" is the complete input filename
1313
*
1414
* Notes:
15-
* This uses the Probabilisitc Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
15+
* This uses the Probabilistic Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
1616
*/
1717

1818
#if !defined(MBEDTLS_CONFIG_FILE)
@@ -53,7 +53,7 @@ int main( void )
5353
#include <string.h>
5454

5555
// Set RSA padding scheme, use PKCS_V21 for PKCS#1 v2.1 PSS probabilistic signatures or PKCS_V15 for older PKCS#1 v1.5
56-
// The RSA Probabilisitc Signature Scheme (PSS) should be used since it is more secure.
56+
// The RSA Probabilistic Signature Scheme (PSS) should be used since it is more secure.
5757
// However, some older encryption libraries only support the older deterministic PKCS#1 v.15 scheme
5858
//#define RSA_PADDING MBEDTLS_RSA_PKCS_V21
5959
#define RSA_PADDING MBEDTLS_RSA_PKCS_V15

rsa_verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* - signature has been saved to filename.sig where "filename" is the complete input filename
1515
*
1616
* Notes:
17-
* This uses the Probabilisitc Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
17+
* This uses the Probabilistic Signature Scheme (PSS) standardized as part of PKCS#1 v2.1 along with SHA-512 hashes.
1818
"""
1919
import sys
2020
import traceback

sodium/Readme.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,45 @@ make
5858
```
5959

6060
This will generate the executables in the build directory.
61+
62+
63+
File Contents
64+
=============
65+
66+
Installation Verification
67+
-------------------------
68+
* hello_sodium.c
69+
* "hello world" code to make sure you have libsodium installed and are linking to it correctly
70+
71+
Symmetric Encryption
72+
--------------------
73+
These examples use the simple [crypto_secretbox](https://download.libsodium.org/doc/secret-key_cryptography/authenticated_encryption.html)
74+
API which is an [authenticated encryption](https://en.wikipedia.org/wiki/Authenticated_encryption) (AE) cryptographic
75+
primitive that combines an [XSalsa20](https://download.libsodium.org/doc/advanced/xsalsa20.html)
76+
stream cipher with a [Poly1305](https://en.wikipedia.org/wiki/Poly1305) MAC. This API is very easy to use and is
77+
particularly suitable for use by newcomers to cryptography. If you have need for authenticating additional data which
78+
is transmitted in an unencrypted fashion, then you may prefer an AEAD primitive instead.
79+
80+
* nacl_symmetric_gen.c
81+
* Generates a random 256-bit (32-byte) secret symmetric key for use with the **secretbox** API
82+
* nacl_encrypt_file.c
83+
* Encrypts a file using libsodium's **secretbox** secret-key authenticated encryption routines and adds a MAC of the ciphertext
84+
* nacl_decrypt_file.c
85+
* Authenticates and decrypts a ciphertext file encrypted using libsodium's **secretbox** secret-key encryption routines
86+
87+
Public-key Digital Signatures
88+
-----------------------------
89+
These examples use the simple [crypto_sign](https://download.libsodium.org/doc/public-key_cryptography/public-key_signatures.html)
90+
API which is a public-key digital signature cryptographic primitive based on elliptic curves and uses the
91+
[Ed25519](https://ed25519.cr.yp.to) algorithm.
92+
93+
* nacl_genkey.c
94+
* Generates a random Ed25519 Secret(signing)/Public(verifying) key pair using libsodium
95+
* nacl_sign.c
96+
* Uses libsodium to sign a message using the Ed25519 digital signature algorithm
97+
* nacl_verify.c
98+
* Uses libsodium to verify a signed message using the Ed25519 digital signature algorithm
99+
* ed25519_sodium_pynacl.c
100+
* Round trip "unit test" of using libsodium Ed25519 digital signature code along with PyNacl digital signature code
101+
102+

sodium/ed25519_sodium_pynacl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
2727
if (sodium_init() < 0)
2828
{
2929
/* panic! the library couldn't be initialized, it is not safe to use */
30-
printf("ERROR: The sodium library couldn't be initialied!\n");
30+
printf("ERROR: The sodium library couldn't be initialized!\n");
3131
return EXIT_FAILURE;
3232
}
3333

0 commit comments

Comments
 (0)