File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -312,12 +312,14 @@ fn sign_rsa(
312312 alg : & ' static dyn signature:: RsaEncoding ,
313313) -> Result < String > {
314314 let key_pair = signature:: RsaKeyPair :: from_pkcs8 ( key)
315+ . map_err ( |e| -> Error { Error :: from ( e) } )
315316 . chain_err ( || "failed to deserialize rsa key" ) ?;
316317
317318 let mut signature = vec ! [ 0 ; key_pair. public_modulus_len( ) ] ;
318319 let rng = ring:: rand:: SystemRandom :: new ( ) ;
319320 key_pair
320321 . sign ( alg, & rng, signing_input. as_bytes ( ) , & mut signature)
322+ . map_err ( |e| -> Error { Error :: from ( e) } )
321323 . chain_err ( || "failed to sign JWT claim" ) ?;
322324
323325 Ok ( base64:: encode_config ( & signature, base64:: URL_SAFE_NO_PAD ) )
Original file line number Diff line number Diff line change @@ -61,6 +61,23 @@ error_chain! {
6161 Which ( err: which:: Error ) {
6262 display( "{}" , err)
6363 }
64+ CryptoError ( msg : String ) {
65+ display( "Cryptographic ops failed: {}" , msg)
66+ }
67+ }
68+ }
69+
70+
71+
72+ impl From < ring:: error:: Unspecified > for Error {
73+ fn from ( e : ring:: error:: Unspecified ) -> Self {
74+ Error :: from ( ErrorKind :: CryptoError ( e. to_string ( ) ) )
75+ }
76+ }
77+
78+ impl From < ring:: error:: KeyRejected > for Error {
79+ fn from ( e : ring:: error:: KeyRejected ) -> Self {
80+ Error :: from ( ErrorKind :: CryptoError ( e. to_string ( ) ) )
6481 }
6582}
6683
You can’t perform that action at this time.
0 commit comments