mirror of
https://github.com/FeitianTech/OpenSK.git
synced 2026-08-28 10:41:01 -07:00
Merge branch 'master' into client-pin-features
This commit is contained in:
@@ -16,6 +16,8 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -9,6 +9,8 @@ jobs:
|
||||
if: github.repository == 'google/OpenSK'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -17,6 +17,8 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -18,6 +18,8 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
@@ -41,6 +43,12 @@ jobs:
|
||||
with:
|
||||
command: fmt
|
||||
args: --manifest-path libraries/cbor/Cargo.toml --all -- --check
|
||||
|
||||
- name: Cargo format libraries/cbor/fuzz
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --manifest-path libraries/cbor/fuzz/Cargo.toml --all -- --check
|
||||
|
||||
- name: Cargo format libraries/crypto
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
@@ -12,6 +12,8 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -13,6 +13,8 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install 'tockloader==1.4' pylint
|
||||
pip install 'tockloader==1.5' pylint
|
||||
- name: Register matcher
|
||||
run: echo ::add-matcher::./.github/python_matcher.json
|
||||
- name: Test code with pylint
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: "true"
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: thumbv7em-none-eabi
|
||||
|
||||
+8
-6
@@ -10,7 +10,9 @@ license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
libtock = { path = "third_party/libtock-rs" }
|
||||
libtock_core = { path = "third_party/libtock-rs/core" }
|
||||
libtock_drivers = { path = "third_party/libtock-drivers" }
|
||||
lang_items = { path = "third_party/lang-items" }
|
||||
cbor = { path = "libraries/cbor" }
|
||||
crypto = { path = "libraries/crypto" }
|
||||
byteorder = { version = "1", default-features = false }
|
||||
@@ -18,12 +20,12 @@ arrayref = "0.3.6"
|
||||
subtle = { version = "2.2", default-features = false, features = ["nightly"] }
|
||||
|
||||
[features]
|
||||
debug_allocations = ["libtock/debug_allocations"]
|
||||
debug_ctap = ["crypto/derive_debug"]
|
||||
panic_console = ["libtock/panic_console"]
|
||||
std = ["cbor/std", "crypto/std", "crypto/derive_debug"]
|
||||
debug_allocations = ["lang_items/debug_allocations"]
|
||||
debug_ctap = ["crypto/derive_debug", "libtock_drivers/debug_ctap"]
|
||||
panic_console = ["lang_items/panic_console"]
|
||||
std = ["cbor/std", "crypto/std", "crypto/derive_debug", "lang_items/std"]
|
||||
ram_storage = []
|
||||
verbose = ["debug_ctap"]
|
||||
verbose = ["debug_ctap", "libtock_drivers/verbose_usb"]
|
||||
with_ctap1 = ["crypto/with_ctap1"]
|
||||
with_ctap2_1 = []
|
||||
|
||||
|
||||
@@ -255,7 +255,6 @@ class RemoveConstAction(argparse.Action):
|
||||
class OpenSKInstaller:
|
||||
|
||||
def __init__(self, args):
|
||||
colorama.init()
|
||||
self.args = args
|
||||
# Where all the TAB files should go
|
||||
self.tab_folder = os.path.join("target", "tab")
|
||||
@@ -373,6 +372,7 @@ class OpenSKInstaller:
|
||||
]
|
||||
env = os.environ.copy()
|
||||
env["RUSTFLAGS"] = " ".join(rust_flags)
|
||||
env["APP_HEAP_SIZE"] = str(APP_HEAP_SIZE)
|
||||
|
||||
command = [
|
||||
"cargo", "build", "--release", "--target={}".format(props.arch),
|
||||
@@ -453,14 +453,10 @@ class OpenSKInstaller:
|
||||
self.args.application, str(e)))
|
||||
|
||||
def get_padding(self):
|
||||
fake_header = tbfh.TBFHeader("")
|
||||
fake_header.version = 2
|
||||
fake_header.fields["header_size"] = 0x10
|
||||
fake_header.fields["total_size"] = (
|
||||
padding = tbfh.TBFHeaderPadding(
|
||||
SUPPORTED_BOARDS[self.args.board].app_address -
|
||||
SUPPORTED_BOARDS[self.args.board].padding_address)
|
||||
fake_header.fields["flags"] = 0
|
||||
return fake_header.get_binary()
|
||||
return padding.get_binary()
|
||||
|
||||
def install_tock_os(self):
|
||||
board_props = SUPPORTED_BOARDS[self.args.board]
|
||||
@@ -542,7 +538,7 @@ class OpenSKInstaller:
|
||||
tock.open()
|
||||
app_found = False
|
||||
with tock._start_communication_with_board():
|
||||
apps = [app.name for app in tock._extract_all_app_headers()]
|
||||
apps = [app.get_name() for app in tock._extract_all_app_headers()]
|
||||
app_found = expected_app in apps
|
||||
return app_found
|
||||
|
||||
@@ -581,16 +577,17 @@ class OpenSKInstaller:
|
||||
"architecture {}".format(board_props.arch)))
|
||||
app_hex = intelhex.IntelHex()
|
||||
app_hex.frombytes(
|
||||
app_tab.extract_app(board_props.arch).get_binary(),
|
||||
app_tab.extract_app(board_props.arch).get_binary(
|
||||
board_props.app_address),
|
||||
offset=board_props.app_address)
|
||||
final_hex.merge(app_hex)
|
||||
info("Generating all-merged HEX file: {}".format(dest_file))
|
||||
final_hex.tofile(dest_file, format="hex")
|
||||
|
||||
def check_prerequisites(self):
|
||||
if not tockloader.__version__.startswith("1.4."):
|
||||
if not tockloader.__version__.startswith("1.5."):
|
||||
fatal(("Your version of tockloader seems incompatible: found {}, "
|
||||
"expected 1.4.x.".format(tockloader.__version__)))
|
||||
"expected 1.5.x.".format(tockloader.__version__)))
|
||||
|
||||
if self.args.programmer == "jlink":
|
||||
assert_mandatory_binary("JLinkExe")
|
||||
@@ -619,18 +616,6 @@ class OpenSKInstaller:
|
||||
assert_python_library("intelhex")
|
||||
|
||||
def run(self):
|
||||
if self.args.listing == "boards":
|
||||
print(os.linesep.join(get_supported_boards()))
|
||||
return 0
|
||||
|
||||
if self.args.listing == "programmers":
|
||||
print(os.linesep.join(PROGRAMMERS))
|
||||
return 0
|
||||
|
||||
if self.args.listing:
|
||||
# Missing check?
|
||||
fatal("Listing {} is not implemented.".format(self.args.listing))
|
||||
|
||||
self.check_prerequisites()
|
||||
self.update_rustc_if_needed()
|
||||
|
||||
@@ -728,9 +713,23 @@ class OpenSKInstaller:
|
||||
|
||||
|
||||
def main(args):
|
||||
colorama.init()
|
||||
|
||||
# Make sure the current working directory is the right one before running
|
||||
os.chdir(os.path.realpath(os.path.dirname(__file__)))
|
||||
|
||||
if args.listing == "boards":
|
||||
print(os.linesep.join(get_supported_boards()))
|
||||
return 0
|
||||
|
||||
if args.listing == "programmers":
|
||||
print(os.linesep.join(PROGRAMMERS))
|
||||
return 0
|
||||
|
||||
if args.listing:
|
||||
# Missing check?
|
||||
fatal("Listing {} is not implemented.".format(args.listing))
|
||||
|
||||
OpenSKInstaller(args).run()
|
||||
|
||||
|
||||
@@ -874,7 +873,12 @@ if __name__ == "__main__":
|
||||
help=("When set, the output of elf2tab is appended to this file."),
|
||||
)
|
||||
|
||||
apps_group = main_parser.add_mutually_exclusive_group(required=True)
|
||||
# Start parsing to know if we're going to list things or not.
|
||||
partial_args, _ = main_parser.parse_known_args()
|
||||
|
||||
# We only need the apps_group if we have a board set
|
||||
apps_group = main_parser.add_mutually_exclusive_group(
|
||||
required=(partial_args.board is not None))
|
||||
apps_group.add_argument(
|
||||
"--no-app",
|
||||
dest="application",
|
||||
@@ -893,8 +897,22 @@ if __name__ == "__main__":
|
||||
dest="application",
|
||||
action="store_const",
|
||||
const="crypto_bench",
|
||||
help=("Compiles and installs the crypto_bench example that tests "
|
||||
help=("Compiles and installs the crypto_bench example that benchmarks "
|
||||
"the performance of the cryptographic algorithms on the board."))
|
||||
apps_group.add_argument(
|
||||
"--panic_test",
|
||||
dest="application",
|
||||
action="store_const",
|
||||
const="panic_test",
|
||||
help=("Compiles and installs the panic_test example that immediately "
|
||||
"triggers a panic."))
|
||||
apps_group.add_argument(
|
||||
"--oom_test",
|
||||
dest="application",
|
||||
action="store_const",
|
||||
const="oom_test",
|
||||
help=("Compiles and installs the oom_test example that tests the "
|
||||
"allocator until an out-of-memory error occurs."))
|
||||
|
||||
main_parser.set_defaults(features=["with_ctap1"])
|
||||
|
||||
|
||||
@@ -17,24 +17,26 @@
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
extern crate crypto;
|
||||
extern crate libtock;
|
||||
extern crate lang_items;
|
||||
extern crate libtock_drivers;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Write;
|
||||
use crypto::{
|
||||
aes256, cbc, ecdsa, rng256, sha256, Decrypt16BytesBlock, Encrypt16BytesBlock, Hash256,
|
||||
};
|
||||
use libtock::console::Console;
|
||||
use libtock::timer;
|
||||
use libtock::timer::Timer;
|
||||
use libtock::timer::Timestamp;
|
||||
use libtock_drivers::console::Console;
|
||||
use libtock_drivers::result::FlexUnwrap;
|
||||
use libtock_drivers::timer;
|
||||
use libtock_drivers::timer::Timer;
|
||||
use libtock_drivers::timer::Timestamp;
|
||||
|
||||
fn main() {
|
||||
let mut console = Console::new();
|
||||
// Setup the timer with a dummy callback (we only care about reading the current time, but the
|
||||
// API forces us to set an alarm callback too).
|
||||
let mut with_callback = timer::with_callback(|_, _| {});
|
||||
let timer = with_callback.init().unwrap();
|
||||
let timer = with_callback.init().flex_unwrap();
|
||||
|
||||
let mut rng = rng256::TockRng256 {};
|
||||
|
||||
@@ -158,11 +160,11 @@ where
|
||||
writeln!(console, "----------------------------------------").unwrap();
|
||||
let mut count = 1;
|
||||
for _ in 0..30 {
|
||||
let start = Timestamp::<f64>::from_clock_value(timer.get_current_clock());
|
||||
let start = Timestamp::<f64>::from_clock_value(timer.get_current_clock().flex_unwrap());
|
||||
for _ in 0..count {
|
||||
f();
|
||||
}
|
||||
let end = Timestamp::<f64>::from_clock_value(timer.get_current_clock());
|
||||
let end = Timestamp::<f64>::from_clock_value(timer.get_current_clock().flex_unwrap());
|
||||
let elapsed = (end - start).ms();
|
||||
writeln!(
|
||||
console,
|
||||
@@ -172,6 +174,7 @@ where
|
||||
elapsed / (count as f64)
|
||||
)
|
||||
.unwrap();
|
||||
console.flush();
|
||||
if elapsed > 1000.0 {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2020 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
extern crate crypto;
|
||||
extern crate lang_items;
|
||||
extern crate libtock_drivers;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Write;
|
||||
use libtock_drivers::console::Console;
|
||||
|
||||
fn main() {
|
||||
writeln!(Console::new(), "****************************************").unwrap();
|
||||
for i in 0.. {
|
||||
writeln!(Console::new(), "Allocating {} bytes...", 1 << i).unwrap();
|
||||
let x: Vec<u8> = Vec::with_capacity(1 << i);
|
||||
writeln!(Console::new(), "Allocated!").unwrap();
|
||||
drop(x);
|
||||
writeln!(Console::new(), "Dropped!").unwrap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2020 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
extern crate crypto;
|
||||
extern crate lang_items;
|
||||
extern crate libtock_drivers;
|
||||
|
||||
fn main() {
|
||||
panic!("Bye world!")
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
[package]
|
||||
name = "cbor-fuzz"
|
||||
version = "0.0.0"
|
||||
authors = ["Automatically generated"]
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = "0.3"
|
||||
|
||||
[dependencies.cbor]
|
||||
path = ".."
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_target_cbor"
|
||||
path = "fuzz_targets/fuzz_target_cbor.rs"
|
||||
test = false
|
||||
doc = false
|
||||
@@ -0,0 +1,15 @@
|
||||
#![no_main]
|
||||
#[macro_use]
|
||||
extern crate libfuzzer_sys;
|
||||
extern crate alloc;
|
||||
extern crate cbor;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if let Ok(value) = cbor::read(data) {
|
||||
let mut result = Vec::new();
|
||||
assert!(cbor::write(value, &mut result));
|
||||
assert_eq!(result, data);
|
||||
};
|
||||
});
|
||||
@@ -10,10 +10,10 @@ license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
libtock = { path = "../../third_party/libtock-rs" }
|
||||
libtock_drivers = { path = "../../third_party/libtock-drivers" }
|
||||
cbor = { path = "../cbor" }
|
||||
arrayref = "0.3.6"
|
||||
subtle = { version = "2.2", default-features = false, features = ["nightly"] }
|
||||
subtle = { version = "2.2.3", default-features = false, features = ["nightly"] }
|
||||
byteorder = { version = "1", default-features = false }
|
||||
hex = { version = "0.3.2", default-features = false, optional = true }
|
||||
ring = { version = "0.16.11", optional = true }
|
||||
|
||||
@@ -21,7 +21,6 @@ extern crate subtle;
|
||||
#[macro_use]
|
||||
extern crate arrayref;
|
||||
extern crate byteorder;
|
||||
extern crate libtock;
|
||||
#[macro_use]
|
||||
extern crate cbor;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use libtock::rng;
|
||||
use libtock_drivers::rng;
|
||||
|
||||
// Lightweight RNG trait to generate uniformly distributed 256 bits.
|
||||
pub trait Rng256 {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user