-
Notifications
You must be signed in to change notification settings - Fork 10
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 #99 from Zondax/dev
Zip32 support
- Loading branch information
Showing
132 changed files
with
2,163 additions
and
774 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# This is the `transaction_version` field of `Runtime` | ||
APPVERSION_M=1 | ||
APPVERSION_M=2 | ||
# This is the `spec_version` field of `Runtime` | ||
APPVERSION_N=0 | ||
# This is the patch version of this release | ||
APPVERSION_P=6 | ||
APPVERSION_P=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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use aes::cipher::generic_array::typenum::{U16, U32, U8}; | ||
use aes::cipher::generic_array::GenericArray; | ||
use aes::cipher::BlockEncrypt; | ||
use aes::cipher::NewBlockCipher; | ||
use aes::cipher::{BlockCipher, BlockCipherKey}; | ||
use aes::Aes256; | ||
|
||
use super::c_zemu_log_stack; | ||
|
||
/// Encrypts a block using AES-256. | ||
/// This function uses the Rust `aes` crate for encryption in test environments. | ||
pub fn aes256_encrypt_block(k: &[u8], a: &[u8]) -> Result<[u8; 16], i32> { | ||
let cipher = Aes256::new(GenericArray::from_slice(k)); | ||
|
||
let mut b = GenericArray::clone_from_slice(a); | ||
cipher.encrypt_block(&mut b); | ||
|
||
// Attempt to convert to [u8; 16], return error if conversion fails | ||
b.as_slice().try_into().map_err(|_| -1) | ||
} | ||
|
||
pub struct AesBOLOS { | ||
key: [u8; 32], | ||
} | ||
|
||
impl AesBOLOS { | ||
pub fn new(k: &[u8; 32]) -> AesBOLOS { | ||
AesBOLOS { key: *k } | ||
} | ||
} | ||
|
||
impl BlockCipher for AesBOLOS { | ||
type BlockSize = U16; | ||
type ParBlocks = U8; | ||
} | ||
|
||
impl BlockEncrypt for AesBOLOS { | ||
#[inline(never)] | ||
fn encrypt_block(&self, block: &mut GenericArray<u8, Self::BlockSize>) { | ||
let x: [u8; 16] = block.as_slice().try_into().expect("err"); | ||
let y = aes256_encrypt_block(&self.key, &x); | ||
if let Ok(y) = y { | ||
block.copy_from_slice(&y); | ||
} | ||
} | ||
} |
Oops, something went wrong.