-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: cargo | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main,dev] | ||
pull_request: | ||
branches: [main,dev] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
CACHE_PATHS: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
jobs: | ||
validity: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.CACHE_PATHS }} | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Check source is valid | ||
run: cargo check --workspace | ||
|
||
formating: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Check Rust formatting with rustfmt | ||
run: cargo fmt --all --check | ||
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | ||
with: | ||
packages: taplo-cli | ||
- name: Check TOML formatting with taplo | ||
run: | | ||
taplo fmt --check **/*/Cargo.toml | ||
tests: | ||
needs: validity | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.CACHE_PATHS }} | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Run all tests | ||
run: cargo test --workspace --verbose --all-features | ||
|
||
clippy: | ||
needs: validity | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.CACHE_PATHS }} | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Lint code with clippy | ||
run: cargo clippy | ||
|
||
publish-ability: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Check that it will publish to crates | ||
run: | | ||
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r _n _v pathInfo ; do | ||
cd ${pathInfo:13:-1} | ||
cargo publish --no-verify --dry-run | ||
done | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Publish crates on crates.io | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
skf-api-version: | ||
description: "major/minor/patch or semver or none if not updating derive crate" | ||
required: false | ||
default: "none" | ||
skf-sys-version: | ||
description: "major/minor/patch or semver or none if not updating derive crate" | ||
required: false | ||
default: "none" | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set git credentials | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
- name: Publish crates | ||
uses: kaleidawave/crates-release-gh-action@main | ||
id: release | ||
with: | ||
version: | | ||
{ | ||
"skf-api": "${{ github.event.inputs.skf-api-version }}", | ||
"skf-sys": "${{ github.event.inputs.skf-sys-version }}" | ||
} | ||
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
- name: Push updated Cargo.toml | ||
run: | | ||
echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do | ||
git tag "release/$update" | ||
done | ||
git add . | ||
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}" | ||
git push --tags origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Rust ### | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
|
||
### IDEA ### | ||
.idea | ||
|
||
# ci dist | ||
/dist | ||
|
||
### others ### | ||
/logs | ||
*.log | ||
*.log.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"skf-api", | ||
"skf-sys" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Rust bindings for GM/T 0016-2012 | ||
|
||
TDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "skf-api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = [ | ||
"CJ <power4j@outlook.com>", | ||
] | ||
description = """ | ||
Rust bindings for GM/T 0016-2012(Smart token cryptography application interface specification). | ||
""" | ||
readme = "README.md" | ||
documentation = "https://docs.rs/skf-api" | ||
repository = "https://github.com/power4j/skf-rs" | ||
license = "MIT" | ||
keywords = ["GM", "cryptography", "PKI"] | ||
categories = ["hardware-support"] | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// FIXME: fix this in the future | ||
#[allow(dead_code)] | ||
pub mod skf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod skf_ffi; | ||
pub mod types; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! GM/T 0016-2012 types | ||
use std::ffi; | ||
|
||
type INT8 = i8; | ||
type INT16 = i16; | ||
type INT32 = i32; | ||
type SHORT = INT16; | ||
type LONG = INT32; | ||
type UINT8 = u8; | ||
type UINT16 = u16; | ||
type UINT32 = u32; | ||
type UINT = INT32; | ||
type USHORT = UINT16; | ||
type ULONG = UINT32; | ||
|
||
type BOOL = bool; | ||
type BYTE = UINT8; | ||
type CHAR = UINT8; | ||
|
||
type WORD = UINT16; | ||
|
||
type DWORD = UINT32; | ||
type FLAGS = UINT32; | ||
|
||
type LPSTR = *const CHAR; | ||
type HANDLE = ffi::c_void; | ||
type HAPPLICATION = HANDLE; | ||
type HCONTAINER = HANDLE; | ||
|
||
/// Version | ||
#[derive(Debug, Copy, Clone)] | ||
#[repr(C)] | ||
#[repr(align(1))] | ||
pub struct Version { | ||
pub major: BYTE, | ||
pub minor: BYTE, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "skf-sys" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = [ | ||
"CJ <power4j@outlook.com>", | ||
] | ||
description = """ | ||
Rust bindings for GM/T 0016-2012(Smart token cryptography application interface specification). | ||
""" | ||
readme = "README.md" | ||
documentation = "https://docs.rs/skf-sys" | ||
repository = "https://github.com/power4j/skf-rs" | ||
license = "MIT" | ||
keywords = ["GM", "cryptography", "PKI"] | ||
categories = ["hardware-support"] | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
skf-api= { path = "../skf-api", version = "0.1.0" } | ||
libloading = "0.8.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use skf_api; | ||
|
||
pub fn version() -> String { | ||
let version = skf_api::skf::types::Version { major: 0, minor: 1 }; | ||
format!("{}.{}", version.major, version.minor) | ||
} |