11
11
// specific language governing permissions and limitations under
12
12
// each license.
13
13
14
- use std:: io:: Write ;
14
+ use std:: { borrow :: Cow , io:: Write } ;
15
15
16
16
use asn1_rs:: FromDer ;
17
17
use async_generic:: async_generic;
@@ -48,12 +48,12 @@ pub enum Verifier<'a> {
48
48
/// Use a [`CertificateTrustPolicy`] to validate the signing certificate's
49
49
/// profile against C2PA requirements _and_ validate the certificate's
50
50
/// membership against a trust configuration.
51
- VerifyTrustPolicy ( & ' a CertificateTrustPolicy ) ,
51
+ VerifyTrustPolicy ( Cow < ' a , CertificateTrustPolicy > ) ,
52
52
53
53
/// Validate the certificate's membership against a trust configuration, but
54
54
/// do not against any trust list. The [`CertificateTrustPolicy`] is used to
55
55
/// enforce EKU (Extended Key Usage) policy only.
56
- VerifyCertificateProfileOnly ( & ' a CertificateTrustPolicy ) ,
56
+ VerifyCertificateProfileOnly ( Cow < ' a , CertificateTrustPolicy > ) ,
57
57
58
58
/// Ignore both trust configuration and trust lists.
59
59
IgnoreProfileAndTrustPolicy ,
@@ -184,8 +184,8 @@ impl Verifier<'_> {
184
184
validation_log : & mut StatusTracker ,
185
185
) -> Result < ( ) , CoseError > {
186
186
let ctp = match self {
187
- Self :: VerifyTrustPolicy ( ctp) => * ctp,
188
- Self :: VerifyCertificateProfileOnly ( ctp) => * ctp,
187
+ Self :: VerifyTrustPolicy ( ref ctp) => ctp,
188
+ Self :: VerifyCertificateProfileOnly ( ref ctp) => ctp,
189
189
Self :: IgnoreProfileAndTrustPolicy => {
190
190
return Ok ( ( ) ) ;
191
191
}
@@ -196,7 +196,7 @@ impl Verifier<'_> {
196
196
197
197
Ok ( check_end_entity_certificate_profile (
198
198
end_entity_cert_der,
199
- ctp,
199
+ ctp. as_ref ( ) ,
200
200
validation_log,
201
201
tst_info,
202
202
) ?)
@@ -213,9 +213,9 @@ impl Verifier<'_> {
213
213
// IMPORTANT: This function assumes that verify_profile has already been called.
214
214
215
215
let ctp = match self {
216
- Self :: VerifyTrustPolicy ( ctp) => * ctp,
216
+ Self :: VerifyTrustPolicy ( ref ctp) => ctp,
217
217
218
- Self :: VerifyCertificateProfileOnly ( _ctp) => {
218
+ Self :: VerifyCertificateProfileOnly ( ref _ctp) => {
219
219
return Ok ( TrustAnchorType :: NoCheck ) ;
220
220
}
221
221
0 commit comments