From 9f26041f31698a6349bfa1271704d4d719749d2c Mon Sep 17 00:00:00 2001 From: Goncalo Frade Date: Sat, 14 Sep 2024 20:07:30 +0100 Subject: [PATCH] fix: c20p and xc20p had the wrong algorithm name --- README.md | 8 +++--- .../ChaChaPoly/C20P+ContentEncryption.swift | 10 +++---- .../ChaChaPoly/XC20P+ContentEncryption.swift | 10 +++---- .../ContentEncryptionAlgorithm.swift | 26 +++++++++---------- .../Decryptors/ECDH1PUDecryptor.swift | 4 +-- .../Decryptors/ECDHDecryptor.swift | 4 +-- .../Encryptors/ECDH1PUEncrypter.swift | 4 +-- .../Encryptors/ECDHEncrypter.swift | 4 +-- .../jose-swift.docc/Articles/JWEEncryption.md | 4 +-- Tests/JWATests/C20PTests.swift | 4 +-- Tests/JWATests/XC20PTests.swift | 4 +-- Tests/JWETests/ECDH1PUTests.swift | 8 +++--- Tests/JWETests/ECDHESTests.swift | 8 +++--- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index e505538..b4441d1 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ This library provides comprehensive support for the Jose suite of standards, inc | A128GCMKW |:white_check_mark:| | A192GCMKW |:white_check_mark:| | A256GCMKW |:white_check_mark:| -| C20PKW |:white_check_mark:| -| XC20PKW |:white_check_mark:| +| C20P |:white_check_mark:| +| XC20P |:white_check_mark:| @@ -359,8 +359,8 @@ Please check our documentation for more on [JWE Encryption](https://beatt83.gith - A128GCM (AES GCM using 128-bit key) - A192GCM (AES GCM using 192-bit key) - A256GCM (AES GCM using 256-bit key) - - C20PKW (ChaCha20-Poly1305) - - XC20PKW (XChaCha20-Poly1305) + - C20P (ChaCha20-Poly1305) + - XC20P (XChaCha20-Poly1305) - Note: ChaChaPoly20-Poly1305 and XChaChaPoly20-Poly1305 is specified in [draft-amringer-jose-chacha-02](https://datatracker.ietf.org/doc/html/draft-amringer-jose-chacha-02) 3. **Compression Algorithms**: diff --git a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/C20P+ContentEncryption.swift b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/C20P+ContentEncryption.swift index 2e8bc48..dedb13a 100644 --- a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/C20P+ContentEncryption.swift +++ b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/C20P+ContentEncryption.swift @@ -1,14 +1,14 @@ import CryptoKit import Foundation -/// `C20PKW` provides methods to encrypt and decrypt data using the ChaCha20-Poly1305 algorithm. -public struct C20PKW: ContentEncryptor, ContentDecryptor { +/// `C20P` provides methods to encrypt and decrypt data using the ChaCha20-Poly1305 algorithm. +public struct C20P: ContentEncryptor, ContentDecryptor { /// The content encryption algorithm used, represented as a string. - public let contentEncryptionAlgorithm: String = ContentEncryptionAlgorithm.c20PKW.rawValue + public let contentEncryptionAlgorithm: String = ContentEncryptionAlgorithm.c20P.rawValue /// The size of the initialization vector in bits. - public let initializationVectorSizeInBits: Int = ContentEncryptionAlgorithm.c20PKW.initializationVectorSizeInBits + public let initializationVectorSizeInBits: Int = ContentEncryptionAlgorithm.c20P.initializationVectorSizeInBits /// The size of the content encryption key (CEK) in bits. - public let cekKeySize: Int = ContentEncryptionAlgorithm.c20PKW.keySizeInBits + public let cekKeySize: Int = ContentEncryptionAlgorithm.c20P.keySizeInBits /// Generates a random initialization vector. /// - Throws: An error if the random data generation fails. diff --git a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift index 2bdd8a6..9d0ef49 100644 --- a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift +++ b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift @@ -1,14 +1,14 @@ import CryptoSwift import Foundation -/// `XC20PKW` provides methods to encrypt and decrypt data using the XChaCha20-Poly1305 algorithm. -public struct XC20PKW: ContentEncryptor, ContentDecryptor { +/// `XC20P` provides methods to encrypt and decrypt data using the XChaCha20-Poly1305 algorithm. +public struct XC20P: ContentEncryptor, ContentDecryptor { /// The content encryption algorithm used, represented as a string. - public let contentEncryptionAlgorithm: String = ContentEncryptionAlgorithm.xC20PKW.rawValue + public let contentEncryptionAlgorithm: String = ContentEncryptionAlgorithm.xC20P.rawValue /// The size of the initialization vector in bits. - public let initializationVectorSizeInBits: Int = ContentEncryptionAlgorithm.xC20PKW.initializationVectorSizeInBits + public let initializationVectorSizeInBits: Int = ContentEncryptionAlgorithm.xC20P.initializationVectorSizeInBits /// The size of the content encryption key (CEK) in bits. - public let cekKeySize: Int = ContentEncryptionAlgorithm.xC20PKW.keySizeInBits + public let cekKeySize: Int = ContentEncryptionAlgorithm.xC20P.keySizeInBits /// Generates a random initialization vector. /// - Throws: An error if the random data generation fails. diff --git a/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift b/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift index 98c129e..46b8405 100644 --- a/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift +++ b/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift @@ -36,11 +36,11 @@ public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable /// ChaCha20-Poly1305 with a 256-bit key and 96 bit IV. /// This algorithm provides robust security and is widely used in various security protocols and systems, it is faster than AES in mobile devices. - case c20PKW = "C20PKW" + case c20P = "C20P" /// XChaCha20-Poly1305 with a 256-bit key and 192 bit IV. /// This algorithm provides robust security and is widely used in various security protocols and systems, it is faster than AES in mobile devices. - case xC20PKW = "XC20PKW" + case xC20P = "XC20P" @@ -54,7 +54,7 @@ public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable case .a128CBCHS256: return 256 case .a192CBCHS384: return 384 case .a256CBCHS512: return 512 - case .c20PKW, .xC20PKW: return 256 + case .c20P, .xC20P: return 256 } } @@ -62,8 +62,8 @@ public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable /// - Returns: The size of the initialization vector in bits. public var initializationVectorSizeInBits: Int { switch self { - case .c20PKW: return 96 - case .xC20PKW: return 192 + case .c20P: return 96 + case .xC20P: return 192 case .a128CBCHS256, .a192CBCHS384, .a256CBCHS512: return 128 case .a128GCM, .a192GCM, .a256GCM: return 96 } @@ -85,10 +85,10 @@ public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable return AES192GCM() case .a256GCM: return AES256GCM() - case .c20PKW: - return C20PKW() - case .xC20PKW: - return XC20PKW() + case .c20P: + return C20P() + case .xC20P: + return XC20P() } } @@ -108,10 +108,10 @@ public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable return AES192GCM() case .a256GCM: return AES256GCM() - case .c20PKW: - return C20PKW() - case .xC20PKW: - return XC20PKW() + case .c20P: + return C20P() + case .xC20P: + return XC20P() } } } diff --git a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDH1PUDecryptor.swift b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDH1PUDecryptor.swift index 5b455ac..1c6dbbb 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDH1PUDecryptor.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDH1PUDecryptor.swift @@ -35,8 +35,8 @@ struct ECDH1PUJWEDecryptor: JWEDecryptor { .a128CBCHS256, .a192CBCHS384, .a256CBCHS512, - .c20PKW, - .xC20PKW + .c20P, + .xC20P ] func decrypt< diff --git a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDHDecryptor.swift b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDHDecryptor.swift index 47a8f29..3ae44a9 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDHDecryptor.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/ECDHDecryptor.swift @@ -35,8 +35,8 @@ struct ECDHJWEDecryptor: JWEDecryptor { .a128CBCHS256, .a192CBCHS384, .a256CBCHS512, - .c20PKW, - .xC20PKW + .c20P, + .xC20P ] func decrypt< diff --git a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDH1PUEncrypter.swift b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDH1PUEncrypter.swift index 1f1180b..f44fe4d 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDH1PUEncrypter.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDH1PUEncrypter.swift @@ -36,8 +36,8 @@ struct ECDH1PUJWEEncryptor: JWEEncryptor { .a128CBCHS256, .a192CBCHS384, .a256CBCHS512, - .c20PKW, - .xC20PKW + .c20P, + .xC20P ] init(masterEphemeralKey: Bool = false) { diff --git a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDHEncrypter.swift b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDHEncrypter.swift index 10458b3..fe3e8c2 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDHEncrypter.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/ECDHEncrypter.swift @@ -35,8 +35,8 @@ struct ECDHJWEEncryptor: JWEEncryptor { .a128CBCHS256, .a192CBCHS384, .a256CBCHS512, - .c20PKW, - .xC20PKW + .c20P, + .xC20P ] init(masterEphemeralKey: Bool = false) { diff --git a/Sources/jose-swift/jose-swift.docc/Articles/JWEEncryption.md b/Sources/jose-swift/jose-swift.docc/Articles/JWEEncryption.md index add8343..64bde48 100644 --- a/Sources/jose-swift/jose-swift.docc/Articles/JWEEncryption.md +++ b/Sources/jose-swift/jose-swift.docc/Articles/JWEEncryption.md @@ -41,8 +41,8 @@ The **jose-swift** library supports a wide range of cryptographic algorithms for - **A128GCM**: AES GCM using 128-bit key - **A192GCM**: AES GCM using 192-bit key - **A256GCM**: AES GCM using 256-bit key -- **C20PKW**: ChaCha20-Poly1305 -- **XC20PKW**: XChaCha20-Poly1305 +- **C20P**: ChaCha20-Poly1305 +- **XC20P**: XChaCha20-Poly1305 - Note: ChaChaPoly20-Poly1305 and XChaChaPoly20-Poly1305 is specified in [draft-amringer-jose-chacha-02](https://datatracker.ietf.org/doc/html/draft-amringer-jose-chacha-02) ### Compression Algorithms diff --git a/Tests/JWATests/C20PTests.swift b/Tests/JWATests/C20PTests.swift index 7b9b51b..8d2c251 100644 --- a/Tests/JWATests/C20PTests.swift +++ b/Tests/JWATests/C20PTests.swift @@ -22,8 +22,8 @@ final class C20PTests: XCTestCase { func testC20PCycle() throws { let payload = "Test".data(using: .utf8)! - let encryptor = ContentEncryptionAlgorithm.c20PKW.encryptor - let decryptor = ContentEncryptionAlgorithm.c20PKW.decryptor + let encryptor = ContentEncryptionAlgorithm.c20P.encryptor + let decryptor = ContentEncryptionAlgorithm.c20P.decryptor let key = try encryptor.generateCEK() let iv = try encryptor.generateInitializationVector() let aad = Data() diff --git a/Tests/JWATests/XC20PTests.swift b/Tests/JWATests/XC20PTests.swift index c924237..e26a614 100644 --- a/Tests/JWATests/XC20PTests.swift +++ b/Tests/JWATests/XC20PTests.swift @@ -22,8 +22,8 @@ final class XC20PTests: XCTestCase { func testXC20PCycle() throws { let payload = "Test".data(using: .utf8)! - let encryptor = ContentEncryptionAlgorithm.xC20PKW.encryptor - let decryptor = ContentEncryptionAlgorithm.xC20PKW.decryptor + let encryptor = ContentEncryptionAlgorithm.xC20P.encryptor + let decryptor = ContentEncryptionAlgorithm.xC20P.decryptor let key = try encryptor.generateCEK() let iv = try encryptor.generateInitializationVector() let aad = Data() diff --git a/Tests/JWETests/ECDH1PUTests.swift b/Tests/JWETests/ECDH1PUTests.swift index 5276e5a..67cdeb3 100644 --- a/Tests/JWETests/ECDH1PUTests.swift +++ b/Tests/JWETests/ECDH1PUTests.swift @@ -202,13 +202,13 @@ final class ECDH1PUTests: XCTestCase { XCTAssertEqual(payload.toHexString(), decrypted.toHexString()) } - func testECDH1PUA256KW_C20PKWCycle() throws { + func testECDH1PUA256KW_C20PCycle() throws { let payload = try "Test".tryToData() let aliceKey = JWK.testingCurve25519KPair let bobKey = JWK.testingCurve25519KPair let keyAlg = KeyManagementAlgorithm.ecdh1PUA256KW - let encAlg = ContentEncryptionAlgorithm.c20PKW + let encAlg = ContentEncryptionAlgorithm.c20P let header = try DefaultJWEHeaderImpl( keyManagementAlgorithm: keyAlg, @@ -238,13 +238,13 @@ final class ECDH1PUTests: XCTestCase { XCTAssertEqual(payload.toHexString(), decrypted.toHexString()) } - func testECDH1PUA256KW_XC20PKWCycle() throws { + func testECDH1PUA256KW_XC20PCycle() throws { let payload = try "Test".tryToData() let aliceKey = JWK.testingCurve25519KPair let bobKey = JWK.testingCurve25519KPair let keyAlg = KeyManagementAlgorithm.ecdh1PUA256KW - let encAlg = ContentEncryptionAlgorithm.xC20PKW + let encAlg = ContentEncryptionAlgorithm.xC20P let header = try DefaultJWEHeaderImpl( keyManagementAlgorithm: keyAlg, diff --git a/Tests/JWETests/ECDHESTests.swift b/Tests/JWETests/ECDHESTests.swift index a1085d3..e90cc03 100644 --- a/Tests/JWETests/ECDHESTests.swift +++ b/Tests/JWETests/ECDHESTests.swift @@ -93,13 +93,13 @@ final class ECDHESTests: XCTestCase { XCTAssertEqual(payload, decrypted) } - func testECDHESA256KW_C20PKWCycle() throws { + func testECDHESA256KW_C20PCycle() throws { let payload = try "Test".tryToData() let aliceKey = JWK.testingES256Pair let bobKey = JWK.testingES256Pair let keyAlg = KeyManagementAlgorithm.ecdhESA128KW - let encAlg = ContentEncryptionAlgorithm.c20PKW + let encAlg = ContentEncryptionAlgorithm.c20P let header = try DefaultJWEHeaderImpl( keyManagementAlgorithm: keyAlg, @@ -129,13 +129,13 @@ final class ECDHESTests: XCTestCase { XCTAssertEqual(payload, decrypted) } - func testECDHESA256KW_XC20PKWCycle() throws { + func testECDHESA256KW_XC20PCycle() throws { let payload = try "Test".tryToData() let aliceKey = JWK.testingES256Pair let bobKey = JWK.testingES256Pair let keyAlg = KeyManagementAlgorithm.ecdhESA128KW - let encAlg = ContentEncryptionAlgorithm.xC20PKW + let encAlg = ContentEncryptionAlgorithm.xC20P let header = try DefaultJWEHeaderImpl( keyManagementAlgorithm: keyAlg,