@@ -17,9 +17,9 @@ use async_generic::async_generic;
17
17
use c2pa_crypto:: {
18
18
asn1:: rfc3161:: TstInfo ,
19
19
cose:: {
20
- check_certificate_profile, parse_cose_sign1, validate_cose_tst_info ,
21
- validate_cose_tst_info_async , CertificateTrustError , CertificateTrustPolicy , CoseError ,
22
- OcspFetchPolicy ,
20
+ check_certificate_profile, parse_cose_sign1, signing_alg_from_sign1 ,
21
+ validate_cose_tst_info , validate_cose_tst_info_async , CertificateTrustError ,
22
+ CertificateTrustPolicy , CoseError , OcspFetchPolicy ,
23
23
} ,
24
24
ocsp:: OcspResponse ,
25
25
p1363:: parse_ec_der_sig,
@@ -33,7 +33,7 @@ use coset::{
33
33
iana:: { self , EnumI64 } ,
34
34
sig_structure_data, Label ,
35
35
} ;
36
- use x509_parser:: { der_parser :: oid , num_bigint:: BigUint , oid_registry :: Oid , prelude:: * } ;
36
+ use x509_parser:: { num_bigint:: BigUint , prelude:: * } ;
37
37
38
38
use crate :: {
39
39
error:: { Error , Result } ,
@@ -134,54 +134,6 @@ fn check_trust(
134
134
135
135
// ---- TEMPORARY MARKER: Above this line will not move to c2pa-crypto
136
136
137
- #[ allow( dead_code) ] // used only in WASM build
138
- pub ( crate ) const SHA1_OID : Oid < ' static > = oid ! ( 1.3 . 14 . 3 . 2 . 26 ) ;
139
-
140
- /********************** Supported Validators ***************************************
141
- RS256 RSASSA-PKCS1-v1_5 using SHA-256 - not recommended
142
- RS384 RSASSA-PKCS1-v1_5 using SHA-384 - not recommended
143
- RS512 RSASSA-PKCS1-v1_5 using SHA-512 - not recommended
144
- PS256 RSASSA-PSS using SHA-256 and MGF1 with SHA-256
145
- PS384 RSASSA-PSS using SHA-384 and MGF1 with SHA-384
146
- PS512 RSASSA-PSS using SHA-512 and MGF1 with SHA-512
147
- ES256 ECDSA using P-256 and SHA-256
148
- ES384 ECDSA using P-384 and SHA-384
149
- ES512 ECDSA using P-521 and SHA-512
150
- ED25519 Edwards Curve 25519
151
- **********************************************************************************/
152
-
153
- pub ( crate ) fn get_signing_alg ( cs1 : & coset:: CoseSign1 ) -> Result < SigningAlg > {
154
- // find the supported handler for the algorithm
155
- match cs1. protected . header . alg {
156
- Some ( ref alg) => match alg {
157
- coset:: RegisteredLabelWithPrivate :: PrivateUse ( a) => match a {
158
- -39 => Ok ( SigningAlg :: Ps512 ) ,
159
- -38 => Ok ( SigningAlg :: Ps384 ) ,
160
- -37 => Ok ( SigningAlg :: Ps256 ) ,
161
- -36 => Ok ( SigningAlg :: Es512 ) ,
162
- -35 => Ok ( SigningAlg :: Es384 ) ,
163
- -7 => Ok ( SigningAlg :: Es256 ) ,
164
- -8 => Ok ( SigningAlg :: Ed25519 ) ,
165
- _ => Err ( Error :: CoseSignatureAlgorithmNotSupported ) ,
166
- } ,
167
- coset:: RegisteredLabelWithPrivate :: Assigned ( a) => match a {
168
- coset:: iana:: Algorithm :: PS512 => Ok ( SigningAlg :: Ps512 ) ,
169
- coset:: iana:: Algorithm :: PS384 => Ok ( SigningAlg :: Ps384 ) ,
170
- coset:: iana:: Algorithm :: PS256 => Ok ( SigningAlg :: Ps256 ) ,
171
- coset:: iana:: Algorithm :: ES512 => Ok ( SigningAlg :: Es512 ) ,
172
- coset:: iana:: Algorithm :: ES384 => Ok ( SigningAlg :: Es384 ) ,
173
- coset:: iana:: Algorithm :: ES256 => Ok ( SigningAlg :: Es256 ) ,
174
- coset:: iana:: Algorithm :: EdDSA => Ok ( SigningAlg :: Ed25519 ) ,
175
- _ => Err ( Error :: CoseSignatureAlgorithmNotSupported ) ,
176
- } ,
177
- coset:: RegisteredLabelWithPrivate :: Text ( a) => a
178
- . parse ( )
179
- . map_err ( |_| Error :: CoseSignatureAlgorithmNotSupported ) ,
180
- } ,
181
- None => Err ( Error :: CoseSignatureAlgorithmNotSupported ) ,
182
- }
183
- }
184
-
185
137
fn get_sign_cert ( sign1 : & coset:: CoseSign1 ) -> Result < Vec < u8 > > {
186
138
// element 0 is the signing cert
187
139
let certs = get_sign_certs ( sign1) ?;
@@ -378,7 +330,7 @@ pub(crate) async fn verify_cose_async(
378
330
) -> Result < ValidationInfo > {
379
331
let mut sign1 = parse_cose_sign1 ( & cose_bytes, & data, validation_log) ?;
380
332
381
- let alg = match get_signing_alg ( & sign1) {
333
+ let alg = match signing_alg_from_sign1 ( & sign1) {
382
334
Ok ( a) => a,
383
335
Err ( _) => {
384
336
log_item ! (
@@ -534,7 +486,7 @@ pub(crate) fn get_signing_info(
534
486
} ;
535
487
issuer_org = extract_subject_from_cert ( & signcert) . ok ( ) ;
536
488
cert_serial_number = Some ( extract_serial_from_cert ( & signcert) ) ;
537
- if let Ok ( a) = get_signing_alg ( & sign1) {
489
+ if let Ok ( a) = signing_alg_from_sign1 ( & sign1) {
538
490
alg = Some ( a) ;
539
491
}
540
492
} ;
@@ -581,7 +533,7 @@ pub(crate) fn verify_cose(
581
533
) -> Result < ValidationInfo > {
582
534
let sign1 = parse_cose_sign1 ( cose_bytes, data, validation_log) ?;
583
535
584
- let alg = match get_signing_alg ( & sign1) {
536
+ let alg = match signing_alg_from_sign1 ( & sign1) {
585
537
Ok ( a) => a,
586
538
Err ( _) => {
587
539
log_item ! (
0 commit comments