Skip to content

Commit 4670dff

Browse files
authored
Update 12-cryptography.livemd
Ready for review
1 parent 29edf8d commit 4670dff

File tree

1 file changed

+24
-58
lines changed

1 file changed

+24
-58
lines changed

modules/12-cryptography.livemd

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Like many concepts/technologies in security, cryptography is not new. Centuries
88
known and trusted senders/receivers while making those messages unreadable for enemies or anyone else for whom the message is not intended.
99
Secret codes, etc.
1010

11-
Cryptography, like speaking or writing in code, is used whenever there something that needs to be kept secret in an environment where there are multiple other parties who could see or hear the secret but are not the intentended receiptient. The sender and receiver agree upon a code to exchange messages. Additionally, written notes can be stored and unless a reader has the code, won't know what the actual message is.
11+
Cryptography, like speaking or writing in code, is used whenever there something that needs to be kept secret in an environment where there are multiple other parties who could see or hear the secret but are not the intended recipient. The sender and receiver agree upon a code to exchange messages. Additionally, written notes can be stored and unless a reader has the code, won't know what the actual message is.
1212

1313
Cryptography is used throughout applications to protect sensitive information that while is needed for the operation of the application and it's components, is not intended to be openly shared. This module highlights how cryptography is applied
1414

@@ -23,7 +23,7 @@ Cryptography is used throughout applications to protect sensitive information th
2323

2424
### Description
2525

26-
There are two categories of cryptography, symmetric and asymmetric and within these categories, there are a variety of algorthims that are distinguished by
26+
There are two categories of cryptography, symmetric and asymmetric and within these categories, there are a variety of algorithms that are distinguished by:
2727
-how data gets chopped up to be encrypted
2828
-how many keys are involved in the encryption/decryption process
2929
-how the keys get generated/used (symmetric/asymmetric)
@@ -32,7 +32,7 @@ There are two categories of cryptography, symmetric and asymmetric and within th
3232

3333
In symmetric encryption, which is also called secret key encryption, a single key used for both encryption and decryption. Symmetric cryptography is bested used when performance and efficiency are important to the application component using/accessing the data to be secured.
3434

35-
In asymmetric encryption, which is also called public-key cryptography, two related but separte keys are generated and then one is used for encrypting while the other for decrpyting. The keys include one that is meant to be shared (pubic key) and one that must always be kept secret(private) but in this public key infrastructure (PKI) system, both keys work to secure client-server interactions, secure VPN connectsion, certificates, digital signatures, and help ensure the technology and data in the system is only accessible by authenticated, and authorized entities with keys.
35+
In asymmetric encryption, which is also called public-key cryptography, two related but separate keys are generated and then one is used for encrypting while the other for decrpyting. The keys include one that is meant to be shared (pubic key) and one that must always be kept secret(private) but in this public key infrastructure (PKI) system, both keys work to secure client-server interactions, secure VPN connectsion, certificates, digital signatures, and help ensure the technology and data in the system is only accessible by authenticated, and authorized entities with keys.
3636

3737
When selecting an algorithm, best practice is to never build your own, and to always use established and proven algorithms, vetted and recommended by industry experts like NIST.
3838

@@ -41,35 +41,20 @@ When selecting an algorithm, best practice is to never build your own, and to al
4141
### <span style="color:blue;">Example</span> / <span style="color:red;">Quiz</span>
4242

4343

44-
*TODO: Make Example or Quiz Question*
45-
46-
```
47-
Older ciphers/algorithms have been proven to be insecure usually due to the weakness of the mathematics invovled in the algorithm or due to the key lenght. Both of these can make it trivial for a malicious actor to decrypt information/data meant to be kept secret.
48-
49-
Newer (Resilient/proven secure by industry)
50-
AES - symmetric; CBC and GCM modes most secure
51-
52-
Diffie-Hellman key exchange
53-
RSA
54-
55-
```
56-
5744
## Implementation in Modern Applications
5845

5946
### Description
6047
Modern applications have many components that store, process, transmit a variety of information and data. Often that information/data consists of "secrets" or is otherwise sensitive. This includes things like personal information on customers, user credentials, of anything else application developers would like to keep secret.
6148

62-
API keys, tokens, passwords and other credentials to access privileged components and features, senstivitve data (PII, healthcare), private keys, signing certificates, are all examples of information that should not be available for every users and indeed, kept internal to the organization.
63-
64-
Much of this information is not static, however, and need sto be transmitted between client and server, stored in databases, used in source code and thus to secure this data, look to implement cryptography both at rest and in transit.
65-
66-
Using. cryptography to protect this information wherever it is in the application, sent between services, stored in databases, used in source code is the best way to ensure it's security and confidentiality.
49+
API keys, database credentials, tokens, admin passwords and other credentials to access privileged components and features, senstivitve data (PII, healthcare), private keys, signing certificates, are all examples of information that should not be available for every users and indeed, kept internal to the organization.
6750

68-
In-transit, dnsure all requests/responses are sent using the secure version of the HTTP protocol, HTTPS. HTTP over TLS. Additionally, For remote access into development environments, SSH, VPN - for access to sensitive development environment internal to an organization/remote accessover a network.
51+
To secure this data, look to implement cryptography both at rest and in transit.
6952

70-
In elixir, https (enabled)
53+
In-transit, ensure all requests/responses are sent using the secure version of the HTTP protocol, HTTPS. HTTP over TLS. Additionally, For remote access into development environments, SSH, VPN - for access to sensitive development environment internal to an organization/remote accessover a network.
7154

7255

56+
### <span style="color:blue;">Example (Draft)</span>
57+
```
7358
For elixir, ExCrypto module[ExCrypto](https://hexdocs.pm/ex_crypto/ExCrypto.html)
7459
7560
Consider what needs to be encrypted - sensitive data or any other data that
@@ -82,56 +67,33 @@ use HTTPS which implements encrpytion over a channel. Diffie-Hellman
8267
[Serving over HTTPS
8368
](https://hexdocs.pm/plug/https.html)
8469
85-
### <span style="color:blue;">Example</span> / <span style="color:red;">Quiz</span>
86-
87-
*TODO: Make Example or Quiz Question*
88-
[
89-
](https://hexdocs.pm/plug/https.html)
9070
[Erlang crypto module](https://elixir-lang.org/getting-started/erlang-libraries.html#the-crypto-module)
91-
```elixir
9271
9372
```
9473

9574
## Related Concepts
9675

9776
### Description
9877

99-
Hash - Sometimes implemented alongside encryption but has a different purpose;
100-
Cryptography used for confidentiality; keeping information secret except for intended recipient/audience. Hashes are used to ensure the
101-
integrity of the data, meaning ensuring from it's creation/generation to it's final state, it remains unmodified and untampered with.
102-
Hashes also used as a substitute for storing data in it's original form. A one way function that - compare starting hash from known good data, to end hash which will indicate changes. Hashing passwords is a common application. Comparing hashes to determine if correct password entered.
103-
Hash Algorithms - SHA1, SHA2, MD5 (obsolete) - follow recommendations from
104-
105-
NIST [Approved Hash Algorithms](https://csrc.nist.gov/Projects/Hash-Functions)
106-
107-
### <span style="color:blue;">Example</span> / <span style="color:red;">Quiz</span>
108-
109-
*TODO: Make Example or Quiz Question*
110-
111-
```elixir
78+
Hashing is sometimes implemented alongside encryption but has a different purpose. Cryptography used for confidentiality; keeping information secret except for intended recipient/audience.
11279

113-
```
80+
Hashes are used to ensure the integrity of the data, meaning ensuring from it's creation/generation to it's final state, it remains unmodified and untampered with. Hash algorithms are one way functions that - compare starting hash from known good data, to end hash which will indicate changes. Hashing passwords is a common application. Comparing hashes to determine if correct password entered.
81+
Hash Algorithms - SHA1, SHA2, MD5 (obsolete) - follow recommendations from NIST [Approved Hash Algorithms](https://csrc.nist.gov/Projects/Hash-Functions)
11482

11583
## Security Concerns
11684

117-
Cryptographic Failures are the number two most common issue on the OWASP Top 10
118-
A02:2021 – Cryptographic Failures
119-
120-
Related weaknesses include
121-
Notable Common Weakness Enumerations (CWEs) include CWE-327: Broken or Risky Crypto Algorithm, and CWE-331 Insufficient Entropy.
85+
Cryptographic Failures are the number two most common issue on the OWASP Top 10 A02:2021 – Cryptographic Failures
12286

123-
All amount to data being inadvertently being sent in cleartext, sensitive data, the use of old, weak or custom cryptographic algorithms or protocols that are ineffective against attacker efforts to uncover keys, . Best practics is to never build your own crypto mechanisms. Use proven and secure:
124-
Secure Hashes: SHA-1 has been deprecated as of 2011 with a transition plan released in 2022. Recommenation to move towards orther families SHA256
125-
Secure Encryption Algorithms; AES is the current standard; secure modes must be emplemented
126-
AES-GCM, AES-CTR, AES-CBC, AESCCM (128, 192, 256-bit keys)
127-
For authentication/TLS RSA, DSA, and ECDSA with 128-bit
128-
security strength (for example, RSA with
129-
3072-bit or larger key)
87+
Related weaknesses include CWE-327: Broken or Risky Crypto Algorithm, and CWE-331 Insufficient Entropy.
13088

131-
Beware of hardcoding keys, private keys, in source code where they can be discovered by malicious actors. Avoid building your own crytographic mechanisms or using outdated protocols.
89+
Most of the concerns around cytography amount to data being inadvertently being sent in cleartext, sensitive data, the use of old, weak or custom cryptographic algorithms or protocols that are ineffective against attacker efforts to uncover keys, . Best practics is to never build your own crypto mechanisms. Use proven and secure methods like the following:
90+
-Secure Hashes: SHA-1 has been deprecated as of 2011 with a transition plan released in 2022. Recommenation to move towards orther families SHA256
91+
-Secure Encryption Algorithms; AES is the current standard; secure modes must be emplemented
13292

13393
Follow NIST Recommendations for configuring the most secure algorithms when building your applications and securing secrets and data.
13494

95+
Beware of hardcoding keys, private keys, in source code where they can be discovered by malicious actors. Avoid building your own crytographic mechanisms or using outdated protocols.
96+
13597
[Recommended algorithms
13698
](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-77r1.pdf)[
13799
NIST](https://www.nist.gov/cryptography)
@@ -142,10 +104,14 @@ https://csrc.nist.gov/Projects/Hash-Functions
142104
[Use TLS](https://cheatsheetseries.owasp.org/cheatsheets/Transport_Layer_Protection_Cheat_Sheet.html)
143105
### <span style="color:blue;">Example</span> / <span style="color:red;">Quiz</span>
144106

145-
*TODO: Make Example or Quiz Question*
107+
**(True or False) You should build your own encryption from scratch.**
108+
*Uncomment the line with your answer
146109

147-
```elixir
110+
```
111+
# answer = True
112+
# answer = False
148113
114+
IO.puts(answer)
149115
```
150116

151117
[**<- Previous Module: Secure SDLC Concepts**](./3-ssdlc.livemd) || [**Next Module: Elixir Security ->**](./5-elixir.livemd)

0 commit comments

Comments
 (0)