@@ -44,27 +44,32 @@ impl crate::HMAC::_default {
4444pub 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 ( ) ;
0 commit comments