File tree 2 files changed +18
-4
lines changed
crates/components/hmac-sha256/src/prf
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change
1
+ //! Provides [`PrfFunction`], for computing the TLS 1.2 PRF.
2
+ //!
3
+ //! If the feature flag `local-inner-hash` is set, provides an implementation which computes
4
+ //! some hashes locally.
5
+
1
6
use crate :: { sha256:: Sha256 , PrfError } ;
2
7
use mpz_circuits:: circuits:: xor;
3
8
use mpz_vm_core:: {
@@ -19,14 +24,22 @@ mod local;
19
24
#[ cfg( feature = "local-inner-hash" ) ]
20
25
pub ( crate ) use local:: PrfFunction ;
21
26
27
+ /// Depending on the provided `mask` computes and returns `outer_partial` or `inner_partial` for
28
+ /// HMAC-SHA256.
29
+ ///
30
+ /// # Arguments
31
+ ///
32
+ /// * `vm` - Virtual machine.
33
+ /// * `key` - Key to pad and xor.
34
+ /// * `mask`- Mask used for padding.
22
35
fn compute_partial (
23
36
vm : & mut dyn Vm < Binary > ,
24
- data : Vector < U8 > ,
37
+ key : Vector < U8 > ,
25
38
mask : [ u8 ; 64 ] ,
26
39
) -> Result < Array < U32 , 8 > , PrfError > {
27
40
let xor = Arc :: new ( xor ( 8 * 64 ) ) ;
28
41
29
- let additional_len = 64 - data . len ( ) ;
42
+ let additional_len = 64 - key . len ( ) ;
30
43
let padding = vec ! [ 0_u8 ; additional_len] ;
31
44
32
45
let padding_ref: Vector < U8 > = vm. alloc_vec ( additional_len) . map_err ( PrfError :: vm) ?;
@@ -40,7 +53,7 @@ fn compute_partial(
40
53
vm. commit ( mask_ref) . map_err ( PrfError :: vm) ?;
41
54
42
55
let xor = Call :: builder ( xor)
43
- . arg ( data )
56
+ . arg ( key )
44
57
. arg ( padding_ref)
45
58
. arg ( mask_ref)
46
59
. build ( )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ use state::State;
17
17
mod function;
18
18
use function:: PrfFunction ;
19
19
20
- /// MPC PRF for computing TLS HMAC-SHA256 PRF.
20
+ /// MPC PRF for computing TLS 1.2 HMAC-SHA256 PRF.
21
21
#[ derive( Debug ) ]
22
22
pub struct MpcPrf {
23
23
state : State ,
@@ -209,6 +209,7 @@ impl MpcPrf {
209
209
}
210
210
}
211
211
212
+ /// Contains the respective [`PrfFunction`]s.
212
213
#[ derive( Debug ) ]
213
214
struct Circuits {
214
215
pub ( crate ) master_secret : PrfFunction ,
You can’t perform that action at this time.
0 commit comments