Merge pull request #979 from GoodNotes/swiftwasm-support

Make CryptoSwift compilable with SwiftWasm
This commit is contained in:
Marcin Krzyzanowski
2022-09-15 15:35:55 +02:00
committed by GitHub
4 changed files with 10 additions and 0 deletions
+2
View File
@@ -23,6 +23,8 @@ import Darwin
import Glibc
#elseif canImport(ucrt)
import ucrt
#elseif canImport(WASILibc)
import WASILibc
#endif
/// Counter with Cipher Block Chaining-Message Authentication Code
+2
View File
@@ -22,6 +22,8 @@ import Darwin
import Glibc
#elseif canImport(ucrt)
import ucrt
#elseif canImport(WASILibc)
import WASILibc
#endif
/// A key derivation function.
+2
View File
@@ -22,6 +22,8 @@ import Darwin
import Glibc
#elseif canImport(ucrt)
import ucrt
#elseif canImport(WASILibc)
import WASILibc
#endif
public extension PKCS5 {
+4
View File
@@ -35,6 +35,8 @@ final class SecureBytes {
self.bytes.withUnsafeBufferPointer { (pointer) -> Void in
#if os(Windows)
VirtualLock(UnsafeMutableRawPointer(mutating: pointer.baseAddress), SIZE_T(pointer.count))
#elseif os(WASI)
// not supported on WASI
#else
mlock(pointer.baseAddress, pointer.count)
#endif
@@ -45,6 +47,8 @@ final class SecureBytes {
self.bytes.withUnsafeBufferPointer { (pointer) -> Void in
#if os(Windows)
VirtualUnlock(UnsafeMutableRawPointer(mutating: pointer.baseAddress), SIZE_T(pointer.count))
#elseif os(WASI)
// not supported on WASI
#else
munlock(pointer.baseAddress, pointer.count)
#endif