Skip to content

Commit

Permalink
fix: vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
beatt83 committed Jan 15, 2024
1 parent 1759a8b commit 22dd8e4
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 41 deletions.
19 changes: 1 addition & 18 deletions Sources/JWA/CryptoImplementation/AES/AESCBC_SHA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ struct AESCBC_SHA<H: HashFunction> {
.withUnsafeBytes { Data($0) }
.prefix(authenticationTagLength)

print("cek: \(Base64URL.encode(cek))")
print("cipher: \(Base64URL.encode(Data(ciphertext)))")
print("encKey: \(Base64URL.encode(encKey))")
print("macKey: \(Base64URL.encode(macKey))")
print("computedTag: \(Base64URL.encode(authenticationTag))")
print("initializationVector: \(Base64URL.encode(initializationVector))")
print("aad: \(Base64URL.encode(additionalAuthenticatedData))")

return (Data(ciphertext), authenticationTag)
}

Expand All @@ -84,16 +76,7 @@ struct AESCBC_SHA<H: HashFunction> {
)
.withUnsafeBytes { Data($0) }
.prefix(authenticationTagLength)

print("cek: \(Base64URL.encode(cek))")
print("cipher: \(Base64URL.encode(cipher))")
print("encKey: \(Base64URL.encode(encKey))")
print("macKey: \(Base64URL.encode(macKey))")
print("computedTag: \(Base64URL.encode(computedTag))")
print("authenticationTag: \(Base64URL.encode(authenticationTag))")
print("initializationVector: \(Base64URL.encode(initializationVector))")
print("aad: \(Base64URL.encode(additionalAuthenticatedData))")


guard authenticationTag == computedTag else {
throw CryptoError.decryptionFailedAuthenticationTagDoesntMatch
}
Expand Down
10 changes: 0 additions & 10 deletions Sources/JWA/CryptoImplementation/AES/AESGCM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,12 @@ struct AESGCM {
initializationVector: Data = Data(),
additionalAuthenticatedData: Data = Data()
) throws -> (cipher: Data, authenticationData: Data) {
print("payload: \(Base64URL.encode(payload))")
print("initializationVector: \(Base64URL.encode(initializationVector))")
print("additionalAuthenticatedData: \(Base64URL.encode(additionalAuthenticatedData))")
print("cek: \(Base64URL.encode(cek))")
let sealedBox = try AES.GCM.seal(
payload,
using: .init(data: cek),
nonce: .init(data: initializationVector),
authenticating: additionalAuthenticatedData
)
print("tag: \(Base64URL.encode(sealedBox.tag))")
return (sealedBox.ciphertext, sealedBox.tag)
}

Expand All @@ -47,11 +42,6 @@ struct AESGCM {
authenticationTag: Data = Data(),
additionalAuthenticatedData: Data = Data()
) throws -> Data {
print("cipher: \(Base64URL.encode(cipher))")
print("initializationVector: \(Base64URL.encode(initializationVector))")
print("additionalAuthenticatedData: \(Base64URL.encode(additionalAuthenticatedData))")
print("tag: \(Base64URL.encode(authenticationTag))")
print("cek: \(Base64URL.encode(using))")
return try AES.GCM.open(
.init(
nonce: .init(data: initializationVector),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ extension ECDHES: KeyDerivation {
let suppPubInfoData = UInt32(keyLengthInBits).bigEndian.dataRepresentation
let suppPrivInfoData = Data()
let tagData = Data()

print("keyZ: \(Base64URL.encode(key))")
print("algorithmIDData: \(Base64URL.encode(algorithmIDData))")
print("partyUInfo: \(Base64URL.encode(partyUInfoData))")
print("partyVInfo: \(Base64URL.encode(partyVInfoData))")
print("suppPubInfoData: \(Base64URL.encode(suppPubInfoData))")
print("tagData: \(Base64URL.encode(tagData))")

return try ConcatKDF<CryptoKit.SHA256>.deriveKey(
z: key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ struct AESKeyUnwrap: KeyUnwrapping {
guard let key = using.key else {
throw CryptoError.missingOctetSequenceKey
}
print("encryptedKey: \(Base64URL.encode(encryptedKey))")
print("keyEncryptionKey: \(Base64URL.encode(key))")


return try AES.KeyWrap.unwrap(
encryptedKey,
using: .init(data: key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ struct AESKeyWrap: KeyWrapping {
.init(data: cek),
using: .init(data: key)
)
print("encryptedKey: \(Base64URL.encode(encryptedKey))")
print("keyEncryptionKey: \(Base64URL.encode(key))")

return .init(
encryptedKey: encryptedKey,
Expand Down
1 change: 0 additions & 1 deletion Sources/JWS/JWS+Json.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ struct JWSJson<P: JWSRegisteredFieldsHeader, H: JWSRegisteredFieldsHeader>: Coda
try? jwk.keyID == $0.getKid()
|| jwk.algorithm == $0.validateAlg()?.rawValue
) ?? false
print(result)
return result
}
}
Expand Down

0 comments on commit 22dd8e4

Please sign in to comment.