Skip to content

Commit af1534a

Browse files
committed
Add warnings in the documentation
1 parent e9fc9af commit af1534a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/ATCryptography/Extensions/P256Extensions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ extension P256.Signing.PublicKey {
1717
/// The compressed form includes only the X coordinate and a prefix byte
1818
/// (0x02 for even Y, 0x03 for odd Y), following the SEC1 standard.
1919
///
20+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
21+
///
2022
/// - Returns: A 33-byte compressed public key.
2123
/// - Throws: An error if the raw representation is invalid or not uncompressed.
2224
internal func compressedRepresentationCompat() throws -> Data {
@@ -44,6 +46,8 @@ extension P256.Signing.PublicKey {
4446
/// This function is designed to support older Apple platforms (iOS/tvOS 13–15)
4547
/// where `.init(compressedRepresentation:)` is unavailable.
4648
///
49+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
50+
///
4751
/// - Parameter compressedKey: The SEC1 compressed public key data.
4852
/// - Returns: A valid `P256.Signing.PublicKey`.
4953
/// - Throws: `P256Error.invalidCompressedKey` or `P256Error.pointNotOnCurve`
@@ -96,6 +100,8 @@ extension P256.Signing.PublicKey {
96100
/// This equation is valid only when `squareRoot` is a quadratic residue modulo `prime`. If `squareRoot`
97101
/// is not a square modulo `prime`, the function returns `nil`.
98102
///
103+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
104+
///
99105
/// - Parameters:
100106
/// - squareRoot: The value whose modular square root is to be computed.
101107
/// - prime: A prime modulus. For p256, this should be the curve's prime field.
@@ -128,6 +134,8 @@ extension Data {
128134
/// This is commonly used to ensure big-endian encoded integers or coordinates are a fixed size, such as
129135
/// 32 bytes for p256 public key components.
130136
///
137+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
138+
///
131139
/// - Parameter length: The target length in bytes.
132140
/// - Returns: A new `Data` instance of exactly `length` bytes, with leading zeroes added if necessary.
133141
/// If the current length is already `>= length`, the original data is returned unchanged.
@@ -148,6 +156,8 @@ internal struct CompressedP256 {
148156

149157
/// Compresses a p256 public key using SEC1 encoding.
150158
///
159+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
160+
///
151161
/// - Parameter key: A valid uncompressed p256 public key.
152162
/// - Returns: A 33-byte compressed SEC1 representation.
153163
///
@@ -168,6 +178,8 @@ internal struct CompressedP256 {
168178
}
169179

170180
/// Errors that may occur while working with compressed p256 keys.
181+
///
182+
/// - Warning: This should only be used for iOS 15 or earlier and tvOS 15 or earlier.
171183
internal enum P256Error: Error {
172184

173185
/// The input data is not a valid compressed p256 key.

0 commit comments

Comments
 (0)