Skip to content

Commit 0c613ce

Browse files
committed
m
1 parent f97abc1 commit 0c613ce

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

DynamoDbEncryption/runtimes/rust/src/hmac.rs

+20-13
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,32 @@ impl crate::HMAC::_default {
4444
pub mod HMAC {
4545
use crate::*;
4646
use aws_lc_rs::hmac;
47+
use std::cell::RefCell;
4748
#[allow(non_camel_case_types)]
4849
pub struct _default {}
4950

5051
#[derive(Debug)]
51-
pub struct HMac {
52-
algorithm: hmac::Algorithm,
52+
pub struct HMacInner {
5353
context: Option<hmac::Context>,
5454
key: Option<hmac::Key>,
5555
}
56+
pub struct HMac {
57+
algorithm: hmac::Algorithm,
58+
inner: RefCell<HMacInner>
59+
}
60+
5661
impl dafny_runtime::UpcastObject<dyn std::any::Any> for HMac {
5762
dafny_runtime::UpcastObjectFn!(dyn std::any::Any);
5863
}
5964

6065
impl HMac {
61-
pub fn Init(&mut self, salt: &::dafny_runtime::Sequence<u8>) {
66+
pub fn Init(&self, salt: &::dafny_runtime::Sequence<u8>) {
6267
let salt: Vec<u8> = salt.iter().collect();
63-
self.key = Some(hmac::Key::new(self.algorithm, &salt));
64-
self.context = Some(hmac::Context::with_key(self.key.as_ref().unwrap()));
68+
self.inner.borrow_mut().key = Some(hmac::Key::new(self.algorithm, &salt));
69+
self.inner.borrow_mut().context = Some(hmac::Context::with_key(self.inner.borrow().key.as_ref().unwrap()));
6570
}
66-
pub fn re_init(&mut self) {
67-
self.context = Some(hmac::Context::with_key(self.key.as_ref().unwrap()));
71+
pub fn re_init(&self) {
72+
self.inner.borrow_mut().context = Some(hmac::Context::with_key(self.inner.borrow().key.as_ref().unwrap()));
6873
}
6974
pub fn Build(
7075
input: &::std::rc::Rc<
@@ -80,18 +85,20 @@ pub mod HMAC {
8085
> {
8186
let inner = dafny_runtime::Object::new(Self {
8287
algorithm: super::convert_algorithm(input),
83-
context: None,
84-
key: None,
88+
inner : RefCell::new(HMacInner {
89+
context: None,
90+
key: None,
91+
})
8592
});
8693

8794
::std::rc::Rc::new(_Wrappers_Compile::Result::Success { value: inner })
8895
}
89-
pub fn BlockUpdate(&mut self, block: &::dafny_runtime::Sequence<u8>) {
96+
pub fn BlockUpdate(&self, block: &::dafny_runtime::Sequence<u8>) {
9097
let part: Vec<u8> = block.iter().collect();
91-
self.context.as_mut().unwrap().update(&part);
98+
self.inner.borrow_mut().context.as_mut().unwrap().update(&part);
9299
}
93-
pub fn GetResult(&mut self) -> ::dafny_runtime::Sequence<u8> {
94-
let inner = self.context.take();
100+
pub fn GetResult(&self) -> ::dafny_runtime::Sequence<u8> {
101+
let inner = self.inner.borrow_mut().context.take();
95102
match inner {
96103
Some(x) => {
97104
let tag = x.sign();

DynamoDbEncryption/runtimes/rust/src/software_externs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ pub mod software {
7676
crate::_Wrappers_Compile::Option::None{} => success_override()
7777
}
7878
}
79-
pub fn EncryptItem(&mut self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemOutput>, Rc<DafnyError>>>{
79+
pub fn EncryptItem(&self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemOutput>, Rc<DafnyError>>>{
8080
todo!("InternalLLegacyOverride::EncryptItem")
8181
}
82-
pub fn DecryptItem(&mut self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemOutput>, Rc<DafnyError>>>{
82+
pub fn DecryptItem(&self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemOutput>, Rc<DafnyError>>>{
8383
todo!("InternalLLegacyOverride::DecryptItem")
8484
}
8585
pub fn IsLegacyInput(

0 commit comments

Comments
 (0)