-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make alloc optional This puts all uses of alloc behind cfg, allowing to run on no_std platforms without alloc. It also sets default-features=false for getrandom and zeroize dependencies, getrandom's `std` or `js` are already set by features. getrandom is made optional since it won't be available on some no_std platforms. It's enabled automatically by `alloc`. * Add CI test for building against bare metal This catches attempting to link to alloc or getrandom which won't work on bare metal platforms. * Add unit test for raw bcrypt()
- Loading branch information
Showing
12 changed files
with
182 additions
and
6 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
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
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
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 @@ | ||
[build] | ||
# Cortex-M0 and Cortex-M0+ | ||
target = "thumbv6m-none-eabi" |
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,10 @@ | ||
[package] | ||
edition = "2021" | ||
name = "bcrypt-bare-metal-test" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
bcrypt = { path = "../../", default-features = false } | ||
|
||
cortex-m-rt = "0.6.10" | ||
panic-halt = "0.2.0" |
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,9 @@ | ||
Bare metal build test | ||
== | ||
|
||
Use by CI to ensure that `bcrypt` with `no-default-features` can work | ||
in a bare metal program. The platform doesn't have any of | ||
`std`, `alloc`, `getrandom`. | ||
|
||
Based on https://github.com/rust-embedded/cortex-m-quickstart | ||
under a MIT license. |
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,43 @@ | ||
//! This build script copies the `memory.x` file from the crate root into | ||
//! a directory where the linker can always find it at build time. | ||
//! For many projects this is optional, as the linker always searches the | ||
//! project root directory -- wherever `Cargo.toml` is. However, if you | ||
//! are using a workspace or have a more complicated build setup, this | ||
//! build script becomes required. Additionally, by requesting that | ||
//! Cargo re-run the build script whenever `memory.x` is changed, | ||
//! updating `memory.x` ensures a rebuild of the application with the | ||
//! new memory settings. | ||
//! | ||
//! The build script also sets the linker flags to tell it which link script to use. | ||
|
||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// Put `memory.x` in our output directory and ensure it's | ||
// on the linker search path. | ||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
File::create(out.join("memory.x")) | ||
.unwrap() | ||
.write_all(include_bytes!("memory.x")) | ||
.unwrap(); | ||
println!("cargo:rustc-link-search={}", out.display()); | ||
|
||
// By default, Cargo will re-run a build script whenever | ||
// any file in the project changes. By specifying `memory.x` | ||
// here, we ensure the build script is only re-run when | ||
// `memory.x` is changed. | ||
println!("cargo:rerun-if-changed=memory.x"); | ||
|
||
// Specify linker arguments. | ||
|
||
// `--nmagic` is required if memory section addresses are not aligned to 0x10000, | ||
// for example the FLASH and RAM sections in your `memory.x`. | ||
// See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 | ||
println!("cargo:rustc-link-arg=--nmagic"); | ||
|
||
// Set the linker script to the one provided by cortex-m-rt. | ||
println!("cargo:rustc-link-arg=-Tlink.x"); | ||
} |
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 @@ | ||
MEMORY | ||
{ | ||
/* These values correspond to the LM3S6965, one of the few devices QEMU can emulate */ | ||
FLASH : ORIGIN = 0x00000000, LENGTH = 256K | ||
RAM : ORIGIN = 0x20000000, LENGTH = 64K | ||
} |
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 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use panic_halt as _; | ||
use cortex_m_rt::entry; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let salt = [1u8; 16]; | ||
let _crypt = bcrypt::bcrypt(6, salt, b"password"); | ||
loop {} | ||
} |
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
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
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