Skip to content

Commit

Permalink
Fix typos and inconsistencies in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-moh committed Feb 14, 2019
1 parent 631cc0d commit 109901f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions JOSESwift/Sources/CryptoImplementation/RSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ internal extension AsymmetricKeyAlgorithm {
///
/// - RSA1_5: For detailed information about the allowed plain text length for RSAES-PKCS1-v1_5,
/// please refer to [RFC-3447, Section 7.2](https://tools.ietf.org/html/rfc3447#section-7.2).
/// - RSAOAEP: For detailed information about the allowed plain text length for RSA-OAEP,
/// - RSAOAEP: For detailed information about the allowed plain text length for RSAES-OAEP,
/// please refer to [RFC-3447, Section 7.1](https://tools.ietf.org/html/rfc3447#section-7.1).
/// - RSAOAEP256: For detailed information about the allowed plain text length for RSA-OAEP-256,
/// - RSAOAEP256: For detailed information about the allowed plain text length for RSAES-OAEP-256,
/// please refer to [RFC-3447, Section 7.1](https://tools.ietf.org/html/rfc3447#section-7.1).
func maxMessageLength(for publicKey: SecKey) -> Int {
let k = SecKeyGetBlockSize(publicKey)
Expand Down Expand Up @@ -122,10 +122,10 @@ fileprivate extension AsymmetricKeyAlgorithm {
// please refer to the RFC(https://tools.ietf.org/html/rfc3447#section-7.2.2).
return cipherText.count == SecKeyGetBlockSize(privateKey)
case .RSAOAEP, .RSAOAEP256:
// For detailed information about the allowed cipher length for RSA-OAEP and RSA-OAEP-256,
// For detailed information about the allowed cipher length for RSAES-OAEP and RSAES-OAEP-256,
// please refer to RFC-3447 (https://tools.ietf.org/html/rfc3447#section-7.1.2,
// https://www.rfc-editor.org/errata_search.php?rfc=3447):
// The ciphertext to be decrypted is an an octet string of length k,
// The ciphertext to be decrypted is an octet string of length k,
// where k is the length in octets of the RSA modulus,
// and k >= 2hLen + 2
return cipherText.count == SecKeyGetBlockSize(privateKey)
Expand Down
2 changes: 1 addition & 1 deletion JOSESwift/Sources/Decrypter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public struct Decrypter {
cek = symmetricKey
} else {
// Generate a random CEK to substitue in case we fail to decrypt the CEK.
// This is to prevent the to prevent MMA (Million Message Attack) against RSA.
// This is to prevent the MMA (Million Message Attack) against RSA.
// For detailed information, please refer to RFC-3218 (https://tools.ietf.org/html/rfc3218#section-2.3.2),
// RFC-5246 (https://tools.ietf.org/html/rfc5246#appendix-F.1.1.2),
// and http://www.ietf.org/mail-archive/web/jose/current/msg01832.html.
Expand Down
8 changes: 4 additions & 4 deletions Tests/JWERSATests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class JWERSATests: RSACryptoTestCase {
//
// System.out.println(jwe.serialize());

let compactSerializedJWERSA1 = """
let compactSerializedJWERSHA1 = """
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0.Od5AMgOHu6rcEYWkX7w_x_wnMlM5JfZaszCC4xtLGYU9d0BnPm95UWUrgSh\
StGH6LHMxpGdru6gXpdxfhhrji12vUIzmkbyNW5M9wjx2t0e4pzzBSYxgOzFoa3jT9a0PcZfyqHIeTrcrTHtpSJ_CIDiZ3MIeqA7hjuRqu2YcTA\
E0v5TPLhHDVRBptkOggA5SL2-gRuUuYoWdanMw_JTHK4utXQZoSY1LTdub_Fh5ez1RqOouc3an5Hx6ImzyJS_cbO_l9xHpHjE7in6SeV9bAZTaY\
EaGnjGKEVaGQ7JiwtTA5rDfVQ5RHSn6blB2Hh5Am7mKzssYu9JjUmr3T-ez_g.M6QnlRxQQ5YS2rF4-wwT3g.4GAtq6fJWJt249SEuK5P_3xJGN\
YP_e_rhz0PVg9QnJXiRl030ggI9GGs3E_0pEPBs9_WJ3E60qQVoXTIMbJXSQ.bQc-W1Ph_0_3kX570pT8gjDlGyiK3kF8PlHiT7GWfMo
""".data(using: .utf8)!

let compactSerializedJWERSAOAEPSHA = """
let compactSerializedJWERSAOAEPSHA1 = """
eyJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiUlNBLU9BRVAifQ.VjoovzQfSQ9zRbPxFR-7suNJesM9yVQrH7tqvEWospcIuYBSQjPTBE6j\
m32iqx9YQd3LiCLqDwz9fzn6_FANSGAYrVgibYX0BqCzN_l83t7YWIa_h43TCgE4sRestYasbqwXY-EfLNK2u37tRxCxxLKDtyugujxNZyQxpOh\
gEA0TzJwwPa2ITX37Z0zF_sAEp_09lF0jWm9u4cVSt-mIIYcpgh5c3sIw1IWs7ynPNWn9Y68YmXJhgeZkIzDiLNGhf3KesH9to4z-EvIyXVBIWl\
Expand All @@ -75,8 +75,8 @@ class JWERSATests: RSACryptoTestCase {

lazy var compactSerializedData: [String: Data] = {
[
AsymmetricKeyAlgorithm.RSA1_5.rawValue: compactSerializedJWERSA1,
AsymmetricKeyAlgorithm.RSAOAEP.rawValue: compactSerializedJWERSAOAEPSHA,
AsymmetricKeyAlgorithm.RSA1_5.rawValue: compactSerializedJWERSHA1,
AsymmetricKeyAlgorithm.RSAOAEP.rawValue: compactSerializedJWERSAOAEPSHA1,
AsymmetricKeyAlgorithm.RSAOAEP256.rawValue: compactSerializedJWERSAOAEPSHA256
]
}()
Expand Down
10 changes: 5 additions & 5 deletions Tests/RSADecrypterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import XCTest

class RSADecrypterTests: RSACryptoTestCase {

// Cipher texts are generated with `openssl rsautl`
// `printf` is used because `echo` appends a newline at the end of the string
// Cipher texts are generated with `openssl rsautl`.
// `printf` is used because `echo` appends a newline at the end of the string.

// printf "The true sign of intelligence is not knowledge but imagination." | openssl rsautl -encrypt -pubin -inkey alice.pub.pem -out >(base64)
let cipherTextWithAliceKeyBase64 = """
Expand All @@ -38,7 +38,7 @@ class RSADecrypterTests: RSACryptoTestCase {
"""

// printf "The true sign of intelligence is not knowledge but imagination." | openssl pkeyutl -encrypt -pubin -inkey alice.pub.pem -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -pkeyopt rsa_mgf1_md:sha256 -out >(base64)
// *NOTE*: openssl v1.1.x is required to encrypt data using RSA-OAEP with SHA256 digest
// *NOTE*: openssl v1.1.x is required to encrypt data using RSAES-OAEP with SHA256 digest.
let cipherTextWithAliceOAEPSHA256Base64 = """
HtL3/k9aiCzON4dEAK930LXvxoWgu2cXHj011FAY4Z++CikiPn5gt/TLFEEV6c4MyMUN8Pj796XwO5a9LRfsV+XWjb5WIAUXewgdKYC1NBFf/q\
Ip+NixeO6oo0nh5NlApJgphRIy1en9ARoz0rIzayt0Py4QOEse7OHLUnDA7PP8vp0X1pyqEG9FZaPViH4+/1zwvEjBVo4N5K4Zl4jqzFYTOkm4\
Expand All @@ -47,7 +47,7 @@ class RSADecrypterTests: RSACryptoTestCase {
"""

// printf "The true sign of intelligence is not knowledge but imagination." | openssl pkeyutl -encrypt -pubin -inkey alice.pub.pem -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha1 -pkeyopt rsa_mgf1_md:sha1 -out >(base64)
// *NOTE*: openssl v1.1.x is required to encrypt data using RSA-OAEP with SHA256 digest
// *NOTE*: openssl v1.1.x is required to encrypt data using RSAES-OAEP with SHA256 digest.
let cipherTextWithAliceOAEPSHA1Base64 = """
bx+Sg8AfSLUGUL/ogL6LZLJdX62N7sYA413SG5sfaAunpyrH3/SCJNTsjQow8zk99jbbiSABWKowDb8tfIwY0SHiU/aKW46f7FeP/70vF2zOefr\
LnVjw1hE9mJi/P7qP66Md8lNC7iRRDtluAHzPE7Hr8E4Xam2lEmZOXsE0lFnHf0eyG23rezGfnJ4lIY40GK926qyjTkSvtHJa57bzfP3Bxj61NK\
Expand All @@ -64,7 +64,7 @@ class RSADecrypterTests: RSACryptoTestCase {
"""

// printf "The true sign of intelligence is not knowledge but imagination." | openssl pkeyutl -encrypt -pubin -inkey bob.pub.pem -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -pkeyopt rsa_mgf1_md:sha256 -out >(base64)
// *NOTE*: openssl v1.1.x is required to encrypt data using RSA-OAEP with SHA256 digest
// *NOTE*: openssl v1.1.x is required to encrypt data using RSAES-OAEP with SHA256 digest.
let cipherTextWithBobKeyOAEPSHA256Base64 = """
IUCsUQzcyL/iuwWpgXK/TgyrsxuSbKKAXq1bd6wlRf7O+9UBlQAenAzXkhRchBOrCYbS1Bs2IwN3gu51RiVsuOg5oHxxKIbtfnbqwtw9beV02oR\
ETCSZ5wPFC/tlYYYloGYR3O47VF5o+NV4qKOE6jbjBEknMAwdN1eoGb0LmF9kUvt9jCLkI1Jt3Cqs8fV9nxqI4Iyzn6hjlvRJk82Ah/q86XfNCQ\
Expand Down

0 comments on commit 109901f

Please sign in to comment.