@@ -31,11 +31,15 @@ extension AES._CBC {
3131 UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8
3232 )
3333
34- private var bytes : IVTuple
34+ var bytes : IVTuple
35+ static var emptyBytes : IVTuple = (
36+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
37+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
38+ )
3539
3640 /// Creates a new random nonce.
3741 public init ( ) {
38- var bytes = IVTuple ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
42+ var bytes = Self . emptyBytes
3943 Swift . withUnsafeMutableBytes ( of: & bytes) {
4044 let count = MemoryLayout< IVTuple> . size
4145 $0. initializeWithRandomBytes ( count: count)
@@ -56,7 +60,7 @@ extension AES._CBC {
5660 throw CryptoKitError . incorrectKeySize
5761 }
5862
59- var bytes = IVTuple ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
63+ var bytes = Self . emptyBytes
6064 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
6165 bytesPtr. copyBytes ( from: ivBytes)
6266 }
@@ -76,7 +80,7 @@ extension AES._CBC {
7680 throw CryptoKitError . incorrectParameterSize
7781 }
7882
79- var bytes = IVTuple ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
83+ var bytes = Self . emptyBytes
8084 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
8185 data. copyBytes ( to: bytesPtr)
8286 }
@@ -123,11 +127,12 @@ extension AES._CFB {
123127 public struct IV : Sendable , ContiguousBytes , Sequence {
124128 typealias IVTuple = ( UInt64 , UInt64 )
125129
126- private var bytes : IVTuple
130+ var bytes : IVTuple
131+ static var emptyBytes : IVTuple = ( 0 , 0 )
127132
128133 /// Creates a new random nonce.
129134 public init ( ) {
130- var bytes = IVTuple ( 0 , 0 )
135+ var bytes = Self . emptyBytes
131136 Swift . withUnsafeMutableBytes ( of: & bytes) {
132137 let count = MemoryLayout< IVTuple> . size
133138 $0. initializeWithRandomBytes ( count: count)
@@ -148,7 +153,7 @@ extension AES._CFB {
148153 throw CryptoKitError . incorrectKeySize
149154 }
150155
151- var bytes = IVTuple ( 0 , 0 )
156+ var bytes = Self . emptyBytes
152157 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
153158 bytesPtr. copyBytes ( from: ivBytes)
154159 }
@@ -168,7 +173,7 @@ extension AES._CFB {
168173 throw CryptoKitError . incorrectParameterSize
169174 }
170175
171- var bytes = IVTuple ( 0 , 0 )
176+ var bytes = Self . emptyBytes
172177 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
173178 data. copyBytes ( to: bytesPtr)
174179 }
@@ -215,11 +220,12 @@ extension AES._CTR {
215220 public struct Nonce : Sendable , ContiguousBytes , Sequence {
216221 typealias NonceTuple = ( UInt64 , UInt32 , UInt32 )
217222
218- private var bytes : NonceTuple
223+ var bytes : NonceTuple
224+ static var emptyBytes : NonceTuple = ( 0 , 0 , 0 )
219225
220226 /// Creates a new random nonce.
221227 public init ( ) {
222- var bytes = NonceTuple ( 0 , 0 , 0 )
228+ var bytes = Self . emptyBytes
223229 Swift . withUnsafeMutableBytes ( of: & bytes) {
224230 let count = MemoryLayout< NonceTuple> . size
225231 $0. initializeWithRandomBytes ( count: count)
@@ -240,7 +246,7 @@ extension AES._CTR {
240246 throw CryptoKitError . incorrectKeySize
241247 }
242248
243- var bytes = NonceTuple ( 0 , 0 , 0 )
249+ var bytes = Self . emptyBytes
244250 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
245251 bytesPtr. copyBytes ( from: nonceBytes)
246252 }
@@ -260,7 +266,7 @@ extension AES._CTR {
260266 throw CryptoKitError . incorrectParameterSize
261267 }
262268
263- var bytes = NonceTuple ( 0 , 0 , 0 )
269+ var bytes = Self . emptyBytes
264270 Swift . withUnsafeMutableBytes ( of: & bytes) { bytesPtr in
265271 data. copyBytes ( to: bytesPtr)
266272 }
0 commit comments