-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from RobertDrazkowskiGL/calib-integration
Add new parsec provider using ATECCx08 cryptochip via CryptoAuthentication Library
- Loading branch information
Showing
14 changed files
with
209 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,15 @@ | ||
FROM ubuntu:18.04 | ||
|
||
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y git make gcc python3 python curl wget cmake && \ | ||
apt-get install -y automake autoconf libtool pkg-config libssl-dev && \ | ||
# These libraries are needed for bindgen as it uses libclang.so | ||
apt-get install -y clang libclang-dev libc6-dev-i386 && \ | ||
# Install cargo globally to not have to install it for each user for multitenancy tests | ||
apt-get install -y cargo | ||
|
||
# Add users for multitenancy tests | ||
RUN useradd -m parsec-client-1 | ||
RUN useradd -m parsec-client-2 |
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,25 @@ | ||
[core_settings] | ||
# The CI already timestamps the logs | ||
log_timestamp = false | ||
log_error_details = true | ||
|
||
# The container runs the Parsec service as root, so make sure we disable root | ||
# checks. | ||
allow_root = true | ||
|
||
[listener] | ||
listener_type = "DomainSocket" | ||
timeout = 200 # in milliseconds | ||
socket_path = "/tmp/parsec.sock" | ||
|
||
[authenticator] | ||
auth_type = "Direct" | ||
|
||
[[key_manager]] | ||
name = "on-disk-manager" | ||
manager_type = "OnDisk" | ||
store_path = "./mappings" | ||
|
||
[[provider]] | ||
provider_type = "CryptoAuthLib" | ||
key_info_manager = "on-disk-manager" |
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
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,102 @@ | ||
// Copyright 2021 Contributors to the Parsec project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
//! Microchip CryptoAuthentication Library provider | ||
//! | ||
//! This provider is a hardware based implementation of PSA Crypto, Mbed Crypto. | ||
use super::Provide; | ||
use crate::authenticators::ApplicationName; | ||
use crate::key_info_managers::ManageKeyInfo; | ||
use derivative::Derivative; | ||
use log::trace; | ||
use parsec_interface::operations::list_keys; | ||
use parsec_interface::operations::list_keys::KeyInfo; | ||
use parsec_interface::operations::list_providers::ProviderInfo; | ||
use parsec_interface::requests::{Opcode, ProviderID, ResponseStatus, Result}; | ||
use std::collections::HashSet; | ||
use std::io::{Error, ErrorKind}; | ||
use std::sync::{Arc, RwLock}; | ||
use uuid::Uuid; | ||
|
||
const SUPPORTED_OPCODES: [Opcode; 0] = []; | ||
|
||
/// CryptoAuthLib provider structure | ||
#[derive(Derivative)] | ||
#[derivative(Debug, Clone, Copy)] | ||
pub struct Provider { | ||
// device: rust_cryptoauthlib::AtcaDevice, | ||
} | ||
|
||
impl Provider { | ||
/// Creates and initialise a new instance of CryptoAuthLibProvider | ||
fn new(_key_info_store: Arc<RwLock<dyn ManageKeyInfo + Send + Sync>>) -> Option<Provider> { | ||
Some(Provider {}) | ||
} | ||
} | ||
|
||
impl Provide for Provider { | ||
fn describe(&self) -> Result<(ProviderInfo, HashSet<Opcode>)> { | ||
trace!("describe ingress"); | ||
Ok((ProviderInfo { | ||
// Assigned UUID for this provider: b8ba81e2-e9f7-4bdd-b096-a29d0019960c | ||
uuid: Uuid::parse_str("b8ba81e2-e9f7-4bdd-b096-a29d0019960c").or(Err(ResponseStatus::InvalidEncoding))?, | ||
description: String::from("User space hardware provider, utilizing MicrochipTech CryptoAuthentication Library for ATECCx08 chips"), | ||
vendor: String::from("Arm"), | ||
version_maj: 0, | ||
version_min: 1, | ||
version_rev: 0, | ||
id: ProviderID::CryptoAuthLib, | ||
}, SUPPORTED_OPCODES.iter().copied().collect())) | ||
} | ||
|
||
fn list_keys( | ||
&self, | ||
_app_name: ApplicationName, | ||
_op: list_keys::Operation, | ||
) -> Result<list_keys::Result> { | ||
trace!("list_keys ingress"); | ||
let keys: Vec<KeyInfo> = Vec::new(); | ||
|
||
Ok(list_keys::Result { keys }) | ||
} | ||
} | ||
|
||
/// CryptoAuthentication Library Provider builder | ||
#[derive(Default, Derivative)] | ||
#[derivative(Debug)] | ||
pub struct ProviderBuilder { | ||
#[derivative(Debug = "ignore")] | ||
key_info_store: Option<Arc<RwLock<dyn ManageKeyInfo + Send + Sync>>>, | ||
} | ||
|
||
impl ProviderBuilder { | ||
/// Create a new CryptoAuthLib builder | ||
pub fn new() -> ProviderBuilder { | ||
ProviderBuilder { | ||
key_info_store: None, | ||
} | ||
} | ||
|
||
/// Add a KeyInfo manager | ||
pub fn with_key_info_store( | ||
mut self, | ||
key_info_store: Arc<RwLock<dyn ManageKeyInfo + Send + Sync>>, | ||
) -> ProviderBuilder { | ||
self.key_info_store = Some(key_info_store); | ||
|
||
self | ||
} | ||
|
||
/// Attempt to build CryptoAuthLib Provider | ||
pub fn build(self) -> std::io::Result<Provider> { | ||
Provider::new( | ||
self.key_info_store | ||
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing key info store"))?, | ||
) | ||
.ok_or_else(|| { | ||
Error::new( | ||
ErrorKind::InvalidData, | ||
"CryptoAuthLib Provider initialization failed", | ||
) | ||
}) | ||
} | ||
} |
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