Skip to content

Commit 3448b87

Browse files
authored
Persistent private keys for agreement (#302)
1 parent 1a1fa0d commit 3448b87

13 files changed

+1154
-530
lines changed

aws-lc-rs/src/agreement.rs

Lines changed: 419 additions & 302 deletions
Large diffs are not rendered by default.

aws-lc-rs/src/agreement/ephemeral.rs

Lines changed: 462 additions & 0 deletions
Large diffs are not rendered by default.

aws-lc-rs/src/bn.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR ISC
33

4-
use crate::ptr::{ConstPointer, DetachableLcPtr};
4+
use crate::ptr::{ConstPointer, DetachableLcPtr, LcPtr};
55
use aws_lc::{BN_bin2bn, BN_bn2bin, BN_cmp, BN_new, BN_num_bits, BN_num_bytes, BN_set_u64, BIGNUM};
66
use mirai_annotations::unrecoverable;
77
use std::cmp::Ordering;
88
use std::ptr::null_mut;
99

10+
impl TryFrom<&[u8]> for LcPtr<BIGNUM> {
11+
type Error = ();
12+
13+
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
14+
unsafe { LcPtr::new(BN_bin2bn(bytes.as_ptr(), bytes.len(), null_mut())) }
15+
}
16+
}
17+
1018
impl TryFrom<&[u8]> for DetachableLcPtr<BIGNUM> {
1119
type Error = ();
1220

0 commit comments

Comments
 (0)