Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename _CryptoExtras to CryptoExtras #281

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ let package = Package(
],
products: [
.library(name: "Crypto", targets: ["Crypto"]),
.library(name: "_CryptoExtras", targets: ["_CryptoExtras"]),
.library(name: "_CryptoExtras", targets: ["CryptoExtras"]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One for discussion - the README is set up that this library won't exist but I've left it here for discussion if we want to keep it to maintain backwards compatibility or not or release this with the upcoming major version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think retaining the backward compatibility is valuable: while the underscore is present, we've tried to avoid gratuitously breaking things and it'd be nice to do so here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I've updated the README. In terms of getting this to work with CMake do I need an shim for _CryptoExtras that points to CryptoExtras?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so.

.library(name: "CryptoExtras", targets: ["CryptoExtras"]),
/* This target is used only for symbol mangling. It's added and removed automatically because it emits build warnings. MANGLE_START
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
MANGLE_END */
Expand Down Expand Up @@ -138,7 +139,7 @@ let package = Package(
swiftSettings: swiftSettings
),
.target(
name: "_CryptoExtras",
name: "CryptoExtras",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims",
Expand Down Expand Up @@ -172,7 +173,7 @@ let package = Package(
],
swiftSettings: swiftSettings
),
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
.testTarget(name: "CryptoExtrasTests", dependencies: ["CryptoExtras"]),
.testTarget(name: "CryptoBoringWrapperTests", dependencies: ["CryptoBoringWrapper"]),
],
cxxLanguageStandard: .cxx11
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When building Swift Crypto for use on Linux, Swift Crypto builds substantially m
2. The common API of Swift Crypto and CryptoKit.
3. The backing implementation of this common API, which calls into BoringSSL.

The API code, and some cryptographic primitives which are directly implemented in Swift, are exactly the same for both Apple CryptoKit and Swift Crypto. The backing BoringSSL-based implementation is unique to Swift Crypto.
The API code, and some cryptographic primitives which are directly implemented in Swift, are exactly the same for both Apple CryptoKit and Swift Crypto. The backing BoringSSL-based implementation is unique to Swift Crypto. In addition, there is another product, `CryptoExtras`, which provides additional functionality that is not offered in CryptoKit, which contains cryptographic APIS predominantly useful in the server ecosystem. **Note**: if you depend on CryptoExtras you'll bundle the BoringSSL implementation of the library in your application, no matter the platform.

## Evolution

Expand Down
2 changes: 1 addition & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ add_subdirectory(CCryptoBoringSSL)
add_subdirectory(CCryptoBoringSSLShims)
add_subdirectory(CryptoBoringWrapper)
add_subdirectory(Crypto)
add_subdirectory(_CryptoExtras)
add_subdirectory(CryptoExtras)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
##
##===----------------------------------------------------------------------===##

add_library(_CryptoExtras
add_library(CryptoExtras
"ChaCha20CTR/BoringSSL/ChaCha20CTR_boring.swift"
"ChaCha20CTR/ChaCha20CTR.swift"
"RSA/RSA+BlindSigning.swift"
Expand All @@ -27,23 +27,23 @@ add_library(_CryptoExtras
"Util/RandomBytes.swift"
"Util/SubjectPublicKeyInfo.swift")

target_include_directories(_CryptoExtras PRIVATE
target_include_directories(CryptoExtras PRIVATE
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:CCryptoBoringSSLShims,INCLUDE_DIRECTORIES>)

target_link_libraries(_CryptoExtras PUBLIC
target_link_libraries(CryptoExtras PUBLIC
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
Crypto
CryptoBoringWrapper
CCryptoBoringSSL
CCryptoBoringSSLShims)

target_compile_options(_CryptoExtras PRIVATE ${SWIFT_CRYPTO_COMPILE_OPTIONS})
target_compile_options(CryptoExtras PRIVATE ${SWIFT_CRYPTO_COMPILE_OPTIONS})

target_link_options(_CryptoExtras PRIVATE
target_link_options(CryptoExtras PRIVATE
"$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")

set_target_properties(_CryptoExtras PROPERTIES
set_target_properties(CryptoExtras PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras)
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CryptoExtras)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

final class AESBlockFunctionTests: XCTestCase {
static let nistPlaintextChunks: [[UInt8]] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

struct AEADTestGroup: Codable {
let ivSize: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Crypto
import Foundation
import _CryptoExtras
import CryptoExtras
import XCTest

final class CBCTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

import Crypto
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest

final class AES_CFBTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Crypto
import Foundation
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest

final class AESCTRTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

class ChaCha20CTRTests: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
import XCTest
import Crypto
@testable import _CryptoExtras
@testable import CryptoExtras

struct RFC9474TestVector: Codable {
var name, p, q, n, e, d, msg, msg_prefix, prepared_msg, salt, inv, blinded_msg, blind_sig, sig: String
Expand Down Expand Up @@ -42,7 +42,7 @@ struct RFC9474TestVector: Codable {
}

static let allValues: [Self] = try! RFC9474TestVector.load(from: URL(
fileURLWithPath: "../_CryptoExtrasVectors/rfc9474.json",
fileURLWithPath: "../CryptoExtrasVectors/rfc9474.json",
relativeTo: URL(fileURLWithPath: #file)
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
import XCTest
import Crypto
import _CryptoExtras // NOTE: No @testable import, because we want to test the public API.
import CryptoExtras // NOTE: No @testable import, because we want to test the public API.

final class TestRSABlindSigningAPI: XCTestCase {
func testEndToEnd() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

final class TestRSAEncryption: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
import XCTest
import Crypto
import CryptoBoringWrapper
@testable import _CryptoExtras
@testable import CryptoExtras

final class TestRSASigning: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct RFCVectorDecoder {

init(bundleType: AnyObject, fileName: String) throws {
let testsDirectory: String = URL(fileURLWithPath: "\(#file)").pathComponents.dropLast(3).joined(separator: "/")
let fileURL: URL? = URL(fileURLWithPath: "\(testsDirectory)/_CryptoExtrasVectors/\(fileName).txt")
let fileURL: URL? = URL(fileURLWithPath: "\(testsDirectory)/CryptoExtrasVectors/\(fileName).txt")

let rfcVectorData = try Data(contentsOf: fileURL!)
self.rfcVectorData = String(decoding: rfcVectorData, as: Unicode.UTF8.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct WycheproofTest<T: Codable>: Codable {
extension XCTestCase {
func wycheproofTest<T: Codable>(jsonName: String, file: StaticString = #file, line: UInt = #line, testFunction: (T) throws -> Void) throws {
let testsDirectory: String = URL(fileURLWithPath: "\(#file)").pathComponents.dropLast(3).joined(separator: "/")
let fileURL: URL? = URL(fileURLWithPath: "\(testsDirectory)/_CryptoExtrasVectors/\(jsonName).json")
let fileURL: URL? = URL(fileURLWithPath: "\(testsDirectory)/CryptoExtrasVectors/\(jsonName).json")

let data = try Data(contentsOf: fileURL!)

Expand Down
2 changes: 1 addition & 1 deletion scripts/update-cmake-lists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ update_cmakelists_source "CCryptoBoringSSL"
update_cmakelists_source "CCryptoBoringSSLShims"
update_cmakelists_source "CryptoBoringWrapper"
update_cmakelists_source "Crypto"
update_cmakelists_source "_CryptoExtras" "*/AES/*.swift"
update_cmakelists_source "CryptoExtras" "*/AES/*.swift"

update_cmakelists_assembly "CCryptoBoringSSL"