File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ tracing = "0.1.40"
30
30
ed25519-dalek = " 2.1.1"
31
31
uuid = " 1.11.0"
32
32
oid-registry = " 0.7.1"
33
+ thiserror = " 2.0.11"
33
34
34
35
c509-certificate = { version = " 0.0.3" , path = " ../c509-certificate" }
35
36
pallas = { version = " 0.30.1" , git = " https://github.com/input-output-hk/catalyst-pallas.git" , rev = " 9b5183c8b90b90fe2cc319d986e933e9518957b3" }
Original file line number Diff line number Diff line change @@ -5,8 +5,17 @@ use anyhow::{anyhow, Context};
5
5
use c509_certificate:: c509:: C509 ;
6
6
use ed25519_dalek:: { VerifyingKey , PUBLIC_KEY_LENGTH } ;
7
7
use oid_registry:: { Oid , OID_SIG_ED25519 } ;
8
+ use thiserror:: Error ;
8
9
use x509_cert:: Certificate as X509Certificate ;
9
10
11
+ /// Error type for unsupported signature algorithms.
12
+ #[ derive( Error , Debug ) ]
13
+ #[ error( "Unsupported signature algorithm: {oid}" ) ]
14
+ pub struct SignatureAlgoError {
15
+ /// An OID of unsupported signature algorithm.
16
+ oid : String ,
17
+ }
18
+
10
19
/// Returns `VerifyingKey` from the given X509 certificate.
11
20
///
12
21
/// # Errors
@@ -51,10 +60,12 @@ pub fn c509_key(cert: &C509) -> anyhow::Result<VerifyingKey> {
51
60
}
52
61
53
62
/// Checks that the signature algorithm is supported.
54
- fn check_signature_algorithm ( oid : & Oid ) -> anyhow :: Result < ( ) > {
63
+ fn check_signature_algorithm ( oid : & Oid ) -> Result < ( ) , SignatureAlgoError > {
55
64
// Currently the only supported signature algorithm is ED25519.
56
65
if * oid != OID_SIG_ED25519 {
57
- return Err ( anyhow ! ( "Unsupported signature algorithm: {oid}" ) ) ;
66
+ return Err ( SignatureAlgoError {
67
+ oid : oid. to_id_string ( ) ,
68
+ } ) ;
58
69
}
59
70
Ok ( ( ) )
60
71
}
You can’t perform that action at this time.
0 commit comments