Преглед изворни кода

Make it compilable with SwiftWasm

Oscar Choi пре 3 година
родитељ
комит
a8bc733bc5

+ 2 - 0
Sources/CryptoSwift/BlockMode/CCM.swift

@@ -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 - 0
Sources/CryptoSwift/HKDF.swift

@@ -22,6 +22,8 @@ import Darwin
 import Glibc
 #elseif canImport(ucrt)
 import ucrt
+#elseif canImport(WASILibc)
+import WASILibc
 #endif
 
 /// A key derivation function.

+ 2 - 0
Sources/CryptoSwift/PKCS/PBKDF2.swift

@@ -22,6 +22,8 @@ import Darwin
 import Glibc
 #elseif canImport(ucrt)
 import ucrt
+#elseif canImport(WASILibc)
+import WASILibc
 #endif
 
 public extension PKCS5 {

+ 4 - 0
Sources/CryptoSwift/SecureBytes.swift

@@ -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