Memory
public class Memory
This class is used to securely store values in memory.
-
The size of the memory region in bytes.
Declaration
Swift
public let sizeInBytes: UInt32
-
The pointer to the secure memory region.
Declaration
Swift
private let pointer: UnsafeMutableRawPointer
-
Allocates a secure memory region. The region is filled with
0xdb
.Declaration
Swift
public init(sizeInBytes: UInt32)
Parameters
sizeInBytes
The size of the memory region in bytes.
-
Copies bytes from a byte array to a secure memory location and wipes the input.
Declaration
Swift
public convenience init(_ bytes: inout Bytes)
Parameters
bytes
The byte array.
-
Deletes secure memory. The memory is overwritten with zeroes.
Declaration
Swift
deinit
-
Make the memory region read only.
Declaration
Swift
private func makeReadOnly()
-
Make the memory region writable.
Declaration
Swift
private func makeReadWritable()
-
Make the memory region inaccessible.
Declaration
Swift
private func makeInaccessible()
-
Read raw bytes memory region.
Usually you do not need to call this function.
Declaration
Swift
public func withUnsafeBytes<ResultType, ContentType>(body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType
Parameters
body
A code block where the memory region is readable.
Return Value
The result from the
body
code block. -
Make changes to the raw bytes of the memory region.
Declaration
Swift
func withUnsafeMutableBytes<ResultType, ContentType>(body: (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType
Parameters
body
A code block where the memory region is writable.
Return Value
The result from the
body
code block.