@@ -13,7 +13,7 @@ use cms::enveloped_data::RecipientInfo::Ktri;
13
13
use cms:: enveloped_data:: { EnvelopedData , RecipientIdentifier , RecipientInfo } ;
14
14
use cms:: signed_data:: { EncapsulatedContentInfo , SignedData , SignerIdentifier } ;
15
15
use const_oid:: ObjectIdentifier ;
16
- use der:: asn1:: { OctetString , PrintableString , SetOfVec , Utf8StringRef } ;
16
+ use der:: asn1:: { OctetString , PrintableString , SetOfVec } ;
17
17
use der:: { Any , AnyRef , Decode , DecodePem , Encode , Tag , Tagged } ;
18
18
use p256:: { pkcs8:: DecodePrivateKey , NistP256 } ;
19
19
use pem_rfc7468:: LineEnding ;
@@ -24,8 +24,7 @@ use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey};
24
24
use sha2:: Sha256 ;
25
25
use signature:: Verifier ;
26
26
use spki:: AlgorithmIdentifierOwned ;
27
- use x509_cert:: attr:: { Attribute , AttributeTypeAndValue , AttributeValue } ;
28
- use x509_cert:: name:: { RdnSequence , RelativeDistinguishedName } ;
27
+ use x509_cert:: attr:: { Attribute , AttributeValue } ;
29
28
use x509_cert:: serial_number:: SerialNumber ;
30
29
31
30
// TODO bk replace this by const_oid definitions as soon as released
@@ -50,30 +49,18 @@ fn ecdsa_signer() -> ecdsa::SigningKey<NistP256> {
50
49
}
51
50
52
51
fn signer_identifier ( id : i32 ) -> SignerIdentifier {
53
- let mut rdn_sequence = RdnSequence :: default ( ) ;
54
- let rdn = & [ AttributeTypeAndValue {
55
- oid : const_oid:: db:: rfc4519:: CN ,
56
- value : Any :: from ( Utf8StringRef :: new ( & format ! ( "test client {id}" ) ) . unwrap ( ) ) ,
57
- } ] ;
58
- let set_of_vector = SetOfVec :: try_from ( rdn. to_vec ( ) ) . unwrap ( ) ;
59
- rdn_sequence. push ( RelativeDistinguishedName :: from ( set_of_vector) ) ;
52
+ let issuer = format ! ( "CN=test client {id}" ) . parse ( ) . unwrap ( ) ;
60
53
SignerIdentifier :: IssuerAndSerialNumber ( IssuerAndSerialNumber {
61
- issuer : rdn_sequence ,
54
+ issuer,
62
55
serial_number : SerialNumber :: new ( & [ 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ] )
63
56
. expect ( "failed to create a serial number" ) ,
64
57
} )
65
58
}
66
59
67
60
fn recipient_identifier ( id : i32 ) -> RecipientIdentifier {
68
- let mut rdn_sequence = RdnSequence :: default ( ) ;
69
- let rdn = & [ AttributeTypeAndValue {
70
- oid : const_oid:: db:: rfc4519:: CN ,
71
- value : Any :: from ( Utf8StringRef :: new ( & format ! ( "test client {id}" ) ) . unwrap ( ) ) ,
72
- } ] ;
73
- let set_of_vector = SetOfVec :: try_from ( rdn. to_vec ( ) ) . unwrap ( ) ;
74
- rdn_sequence. push ( RelativeDistinguishedName :: from ( set_of_vector) ) ;
61
+ let issuer = format ! ( "CN=test client {id}" ) . parse ( ) . unwrap ( ) ;
75
62
RecipientIdentifier :: IssuerAndSerialNumber ( IssuerAndSerialNumber {
76
- issuer : rdn_sequence ,
63
+ issuer,
77
64
serial_number : SerialNumber :: new ( & [ 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ] )
78
65
. expect ( "failed to create a serial number" ) ,
79
66
} )
0 commit comments