Skip to content

Commit

Permalink
Merge pull request #1065 from marcprux/master
Browse files Browse the repository at this point in the history
Add Android support
  • Loading branch information
krzyzanowskim authored Jan 5, 2025
2 parents 3023636 + 1e30a61 commit 98e2219
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Android

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run tests
uses: skiptools/swift-android-action@v2
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/BlockMode/CCM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/Cryptors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/HKDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/Int+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/PKCS/PBKDF2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/SHA3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
6 changes: 6 additions & 0 deletions Sources/CryptoSwift/SecureBytes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand All @@ -39,6 +41,8 @@ final class SecureBytes {
VirtualLock(UnsafeMutableRawPointer(mutating: pointer.baseAddress), SIZE_T(pointer.count))
#elseif os(WASI)
// not supported on WASI
#elseif os(Android)
mlock(pointer.baseAddress!, pointer.count)
#else
mlock(pointer.baseAddress, pointer.count)
#endif
Expand All @@ -51,6 +55,8 @@ final class SecureBytes {
VirtualUnlock(UnsafeMutableRawPointer(mutating: pointer.baseAddress), SIZE_T(pointer.count))
#elseif os(WASI)
// not supported on WASI
#elseif os(Android)
munlock(pointer.baseAddress!, pointer.count)
#else
munlock(pointer.baseAddress, pointer.count)
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/UInt32+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CryptoSwift/UInt8+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if canImport(Darwin)
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
Expand Down

0 comments on commit 98e2219

Please sign in to comment.