Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Android support #1065

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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