1
1
use crate :: headers:: CONTENT_MD5 ;
2
2
use crate :: {
3
3
core:: { ConnectionString , No } ,
4
+ hmac:: sign,
4
5
shared_access_signature:: account_sas:: {
5
6
AccountSharedAccessSignatureBuilder , ClientAccountSharedAccessSignature ,
6
7
} ,
@@ -13,7 +14,6 @@ use http::{
13
14
method:: Method ,
14
15
request:: { Builder , Request } ,
15
16
} ;
16
- use ring:: hmac;
17
17
use std:: sync:: Arc ;
18
18
use url:: Url ;
19
19
@@ -450,22 +450,12 @@ fn generate_authorization(
450
450
// debug!("\nstr_to_sign == {:?}\n", str_to_sign);
451
451
// debug!("str_to_sign == {}", str_to_sign);
452
452
453
- let auth = encode_str_to_sign ( & str_to_sign, key) ;
453
+ let auth = sign ( & str_to_sign, key) . unwrap ( ) ;
454
454
// debug!("auth == {:?}", auth);
455
455
456
456
format ! ( "SharedKey {}:{}" , account, auth)
457
457
}
458
458
459
- fn encode_str_to_sign ( str_to_sign : & str , hmac_key : & str ) -> String {
460
- let key = hmac:: Key :: new ( ring:: hmac:: HMAC_SHA256 , & base64:: decode ( hmac_key) . unwrap ( ) ) ;
461
- let sig = hmac:: sign ( & key, str_to_sign. as_bytes ( ) ) ;
462
-
463
- // let res = hmac.result();
464
- // debug!("{:?}", res.code());
465
-
466
- base64:: encode ( sig. as_ref ( ) )
467
- }
468
-
469
459
fn add_if_exists < K : AsHeaderName > ( h : & HeaderMap , key : K ) -> & str {
470
460
match h. get ( key) {
471
461
Some ( ce) => ce. to_str ( ) . unwrap ( ) ,
0 commit comments