-
Notifications
You must be signed in to change notification settings - Fork 5
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
0 parents
commit 543402f
Showing
9 changed files
with
286 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,2 @@ | ||
target | ||
Cargo.lock |
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,28 @@ | ||
language: rust | ||
|
||
os: | ||
- osx | ||
|
||
cache: cargo | ||
|
||
rust: | ||
- nightly | ||
- beta | ||
- stable | ||
|
||
matrix: | ||
allow_failures: | ||
- rust: nightly | ||
|
||
before_script: ci/before_script.sh | ||
script: ci/script.sh | ||
after_success: | ||
- travis-cargo --only stable doc-upload | ||
- travis-cargo --only stable coveralls --no-sudo --verify --exclude-pattern=/test.rs | ||
|
||
env: | ||
global: | ||
- TRAVIS_CARGO_NIGHTLY_FEATURE='lint' | ||
- PATH=$HOME/Library/Python/2.7/bin:$PATH | ||
# encrypted github token for doc upload | ||
- secure: euCXRgSy9cmwmYqigfnM9EQq839onxlWYfVsQf5mw8ERIrKYyVAP1Ca3YVc6IE4klLFDuJIiK7fWCIOAQwTYB5EEc8JigSTum70C4Vmb8U0Ms7L4V2eZ9u45UGR1nf3G2rU4Oo/FxctioAMG9T41J/3l86FgKJEWffQUJqHamknW8l05ZuIkp0qilpUZqTji9eZRX91NidCmMpvJYPBKru40Z7piOLtnpb/r/Ix/iqPCMste5US8KWKtwZoHcJC/Ofu95sN06aoGG37JGn9z4rICSG9v2NcRzMaQ3B4goTRWQ/8wgNh0mt+0MR213Ay7HTjjk8TKKsUB9mNFTyvVoWYAO5vC+LNZLzzogWF2IbhI6If/CcdpHw1Rs9wxs310YlzSPgU1ZON0gRVQj9AYHK436PIPwuBO+pmsAh9ap1ALOnICa5lBvNudNlTL8gOZcYM7EpglBgGsBoAONZWoKv0+Ymm4MFDgVwi8C5oEfz3sdievpfPpl42BWmHsPb99mqZaGxQ76pitTFOYATmgmli7IENq8s9tDur6j0OX6hTR4o41BWQLGTruQG8pexWQ5r3ZryxGjRXAP5xwEz+5zzkQp3RysmcSUCS/lKPPWt7VuRGPdlM49It7uyBD/sPe2fBesEMqvcK94QMNL/xyxkkMcTVnzqSpX81qwEYcJpY= |
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,67 @@ | ||
# Contributing to commoncrypto-sys | ||
|
||
commoncrypto-sys is a part of the Rust ecosystem. As such, all contributions to this project follow | ||
the [Rust language's code of conduct](https://www.rust-lang.org/conduct.html) where appropriate. | ||
|
||
This project is hosted at [GitHub](https://github.com/malept/commoncrypto-sys). Both pull requests | ||
and issues of many different kinds are accepted. | ||
|
||
## Filing Issues | ||
|
||
Issues include bugs, questions, feedback, and feature requests. Before you file a new issue, please | ||
make sure that your issue has not already been filed by someone else. | ||
|
||
### Filing Bugs | ||
|
||
When filing a bug, please include the following information: | ||
|
||
* Rust version that compiled commoncrypto-sys. | ||
* The version (and/or git revision) of commoncrypto-sys. | ||
* A detailed list of steps to reproduce the bug. A minimal testcase would be very helpful, | ||
if possible. | ||
* If there any any error messages in the console, copying them in the bug summary will be | ||
very helpful. | ||
|
||
## Filing Pull Requests | ||
|
||
Here are some things to keep in mind as you file a pull request to fix a bug, add a new feature, | ||
etc.: | ||
|
||
* Travis CI is used to make sure that the project builds as expected on the supported platforms, | ||
* using the current stable and beta versions of Rust. | ||
Make sure the testsuite passes locally by running `cargo test`. | ||
* Unless it's impractical, please write tests for your changes. This will help spot regressions | ||
much easier. | ||
* If your PR changes the behavior of an existing feature, or adds a new feature, please add/edit | ||
the `rustdoc` inline documentation. | ||
* Please ensure that your changes follow the [rustfmt](https://github.com/rust-lang-nursery/rustfmt) | ||
coding standard, and do not produce any warnings when running the | ||
[clippy](https://github.com/Manishearth/rust-clippy) linter. | ||
* If you are contributing a nontrivial change, please add an entry to `NEWS.md`. The format is | ||
similar to the one described at [Keep a Changelog](http://keepachangelog.com/). | ||
* Please **do not** bump the version number in your pull requests, the maintainers will do that. | ||
Feel free to indicate whether the changes require a major, minor, or patch version bump, as | ||
prescribed by the [semantic versioning specification](http://semver.org/). | ||
* Please make sure your commits are rebased onto the latest commit in the master branch, and that | ||
you limit/squash the number of commits created to a "feature"-level. For instance: | ||
|
||
bad: | ||
|
||
``` | ||
commit 1: add foo | ||
commit 2: run rustfmt | ||
commit 3: add test | ||
commit 4: add docs | ||
commit 5: add bar | ||
commit 6: add test + docs | ||
``` | ||
|
||
good: | ||
|
||
``` | ||
commit 1: add foo | ||
commit 2: add bar | ||
``` | ||
|
||
If you are continuing the work of another person's PR and need to rebase/squash, please retain the | ||
attribution of the original author(s) and continue the work in subsequent commits. |
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,22 @@ | ||
[package] | ||
name = "commoncrypto-sys" | ||
version = "0.1.0" | ||
authors = ["Mark Lee"] | ||
description = "FFI bindings to Mac OS X's CommonCrypto library" | ||
documentation = "https://malept.github.io/commoncrypto-sys/" | ||
repository = "https://github.com/malept/commoncrypto-sys" | ||
readme = "README.md" | ||
keywords = ["crypto", "hash", "digest"] | ||
license = "MIT" | ||
exclude = [ | ||
".*.yml", | ||
"ci/*" | ||
] | ||
|
||
[features] | ||
lint = ["clippy"] | ||
|
||
[dependencies] | ||
libc = "0.2" | ||
|
||
clippy = { version = "0.0", optional = true } |
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 @@ | ||
Copyright (c) 2016 Mark Lee | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,20 @@ | ||
# `commoncrypto-sys` | ||
|
||
[](https://travis-ci.org/malept/commoncrypto-sys) | ||
|
||
Rust FFI bindings for Mac OS X's CommonCrypto library. | ||
|
||
## Requirements | ||
|
||
OS X or macOS | ||
|
||
## Usage | ||
|
||
Add `commoncrypto-sys` to your project's `Cargo.toml`. For more details, consult the | ||
[Cargo guide](http://doc.crates.io/guide.html#adding-dependencies-from-cratesio). | ||
|
||
## [Contributing](https://github.com/malept/commoncrypto-sys/blob/master/CONTRIBUTING.md) | ||
|
||
## Legal | ||
|
||
`commoncrypto-sys` is copyrighted under the terms of the MIT license. See LICENSE for details. |
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,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# load travis-cargo | ||
pip install 'travis-cargo<0.2' --user | ||
|
||
if test "$TRAVIS_RUST_VERSION" = "nightly"; then | ||
if ! cargo install --list | grep -q clippy; then | ||
cargo install clippy | ||
fi | ||
fi |
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,12 @@ | ||
#!/bin/bash | ||
|
||
# the main build | ||
set -e | ||
|
||
travis-cargo build | ||
travis-cargo test | ||
travis-cargo --only stable doc | ||
|
||
if test "$TRAVIS_RUST_VERSION" = "nightly"; then | ||
cargo clippy --features=$TRAVIS_CARGO_NIGHTLY_FEATURE -- -Wclippy_pedantic | ||
fi |
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,104 @@ | ||
// Copyright (c) 2016 Mark Lee | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
//! Low-level bindings to OSX/macOS/iOS's `CommonCrypto` library. | ||
#![warn(missing_docs)] | ||
|
||
extern crate libc; | ||
|
||
use libc::{c_int, c_uint, c_ulong, c_ulonglong}; | ||
|
||
pub const MD5_CBLOCK: usize = 64; | ||
pub const MD5_LBLOCK: usize = MD5_CBLOCK / 4; | ||
pub const MD5_DIGEST_LENGTH: usize = 16; | ||
|
||
pub const SHA_LBLOCK: usize = 16; | ||
pub const SHA1_DIGEST_LENGTH: usize = 20; | ||
pub const SHA256_DIGEST_LENGTH: usize = 32; | ||
pub const SHA512_DIGEST_LENGTH: usize = 64; | ||
|
||
#[allow(non_camel_case_types, non_snake_case)] | ||
#[derive(Clone, Debug, Default, PartialEq)] | ||
#[repr(C)] | ||
pub struct CC_MD5_CTX { | ||
A: c_uint, | ||
B: c_uint, | ||
C: c_uint, | ||
D: c_uint, | ||
Nl: c_uint, | ||
Nh: c_uint, | ||
data: [c_uint; MD5_LBLOCK], | ||
num: c_uint, | ||
} | ||
|
||
#[allow(non_camel_case_types, non_snake_case)] | ||
#[derive(Clone, Debug, Default, PartialEq)] | ||
#[repr(C)] | ||
pub struct CC_SHA_CTX { | ||
h0: c_uint, | ||
h1: c_uint, | ||
h2: c_uint, | ||
h3: c_uint, | ||
h4: c_uint, | ||
Nl: c_uint, | ||
Nh: c_uint, | ||
data: [c_uint; SHA_LBLOCK], | ||
num: c_uint, | ||
} | ||
|
||
#[allow(non_camel_case_types, non_snake_case)] | ||
#[derive(Clone, Debug, Default, PartialEq)] | ||
#[repr(C)] | ||
pub struct CC_SHA256_CTX { | ||
h: [c_ulong; 8], | ||
Nl: c_ulong, | ||
Nh: c_ulong, | ||
data: [c_ulong; SHA_LBLOCK], | ||
num: c_uint, | ||
md_len: c_uint, | ||
} | ||
|
||
#[allow(non_camel_case_types, non_snake_case)] | ||
#[derive(Clone, Debug, Default, PartialEq)] | ||
#[repr(C)] | ||
pub struct CC_SHA512_CTX { | ||
h: [c_ulonglong; 8], | ||
Nl: c_ulonglong, | ||
Nh: c_ulonglong, | ||
data: [c_ulonglong; SHA_LBLOCK], | ||
num: c_uint, | ||
md_len: c_uint, | ||
} | ||
|
||
extern "C" { | ||
pub fn CC_MD5_Init(ctx: *mut CC_MD5_CTX) -> c_int; | ||
pub fn CC_MD5_Update(ctx: *mut CC_MD5_CTX, data: *const u8, n: usize) -> c_int; | ||
pub fn CC_MD5_Final(md: *mut u8, ctx: *mut CC_MD5_CTX) -> c_int; | ||
pub fn CC_SHA1_Init(ctx: *mut CC_SHA_CTX) -> c_int; | ||
pub fn CC_SHA1_Update(ctx: *mut CC_SHA_CTX, data: *const u8, n: usize) -> c_int; | ||
pub fn CC_SHA1_Final(md: *mut u8, ctx: *mut CC_SHA_CTX) -> c_int; | ||
pub fn CC_SHA256_Init(ctx: *mut CC_SHA256_CTX) -> c_int; | ||
pub fn CC_SHA256_Update(ctx: *mut CC_SHA256_CTX, data: *const u8, n: usize) -> c_int; | ||
pub fn CC_SHA256_Final(md: *mut u8, ctx: *mut CC_SHA256_CTX) -> c_int; | ||
pub fn CC_SHA512_Init(ctx: *mut CC_SHA512_CTX) -> c_int; | ||
pub fn CC_SHA512_Update(ctx: *mut CC_SHA512_CTX, data: *const u8, n: usize) -> c_int; | ||
pub fn CC_SHA512_Final(md: *mut u8, ctx: *mut CC_SHA512_CTX) -> c_int; | ||
} |