@@ -44,27 +44,32 @@ impl crate::HMAC::_default {
44
44
pub mod HMAC {
45
45
use crate :: * ;
46
46
use aws_lc_rs:: hmac;
47
+ use std:: cell:: RefCell ;
47
48
#[ allow( non_camel_case_types) ]
48
49
pub struct _default { }
49
50
50
51
#[ derive( Debug ) ]
51
- pub struct HMac {
52
- algorithm : hmac:: Algorithm ,
52
+ pub struct HMacInner {
53
53
context : Option < hmac:: Context > ,
54
54
key : Option < hmac:: Key > ,
55
55
}
56
+ pub struct HMac {
57
+ algorithm : hmac:: Algorithm ,
58
+ inner : RefCell < HMacInner >
59
+ }
60
+
56
61
impl dafny_runtime:: UpcastObject < dyn std:: any:: Any > for HMac {
57
62
dafny_runtime:: UpcastObjectFn !( dyn std:: any:: Any ) ;
58
63
}
59
64
60
65
impl HMac {
61
- pub fn Init ( & mut self , salt : & :: dafny_runtime:: Sequence < u8 > ) {
66
+ pub fn Init ( & self , salt : & :: dafny_runtime:: Sequence < u8 > ) {
62
67
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 ( ) ) ) ;
65
70
}
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 ( ) ) ) ;
68
73
}
69
74
pub fn Build (
70
75
input : & :: std:: rc:: Rc <
@@ -80,18 +85,20 @@ pub mod HMAC {
80
85
> {
81
86
let inner = dafny_runtime:: Object :: new ( Self {
82
87
algorithm : super :: convert_algorithm ( input) ,
83
- context : None ,
84
- key : None ,
88
+ inner : RefCell :: new ( HMacInner {
89
+ context : None ,
90
+ key : None ,
91
+ } )
85
92
} ) ;
86
93
87
94
:: std:: rc:: Rc :: new ( _Wrappers_Compile:: Result :: Success { value : inner } )
88
95
}
89
- pub fn BlockUpdate ( & mut self , block : & :: dafny_runtime:: Sequence < u8 > ) {
96
+ pub fn BlockUpdate ( & self , block : & :: dafny_runtime:: Sequence < u8 > ) {
90
97
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) ;
92
99
}
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 ( ) ;
95
102
match inner {
96
103
Some ( x) => {
97
104
let tag = x. sign ( ) ;
0 commit comments