@@ -139,6 +139,10 @@ fn decode_signed_scep_example() {
139
139
}
140
140
_ => panic!("expected ContentInfo::SignedData(Some(_))"),
141
141
}
142
+
143
+ let mut buf = vec![0u8; bytes.len()];
144
+ let encoded_content = encode_content_info(&content, &mut buf);
145
+ println!("{:?}", encoded_content);
142
146
}
143
147
144
148
// TODO(tarcieri): BER support
@@ -186,3 +190,55 @@ fn decode_signed_der() {
186
190
10034
187
191
);
188
192
}
193
+
194
+ use pkcs7::{
195
+ signed_data_content::{CertificateSet, DigestAlgorithmIdentifier, DigestAlgorithmIdentifiers},
196
+ signer_info::{SignerInfo, SignerInfos},
197
+ };
198
+
199
+ const OID_ED25519: &str = "1.3.101.112"; // {iso(1) identified-organization(3) thawte(101) id-Ed25519(112)}
200
+ const OID_PKCS7_SIGNED_DATA: &str = "1.2.840.113549.1.7.2"; // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-7(7) signedData(2)}
201
+
202
+ #[test]
203
+ fn test_make_pkcs7_signed_data() {
204
+
205
+ let content_info = ContentInfo::SignedData(SignedDataContent {
206
+ version: pkcs7::cms_version::CmsVersion::V1,
207
+ digest_algorithms: get_digest_algorithms(),
208
+ encap_content_info: get_encap_content_info(),
209
+ certificates: get_certificates(),
210
+ crls: None,
211
+ signer_infos: get_signer_infos(),
212
+ });
213
+
214
+ let mut buf = vec![0u8; 10000];
215
+ let _encoded_content = encode_content_info(&content_info, &mut buf);
216
+ }
217
+
218
+ fn get_digest_algorithms<'a>() -> DigestAlgorithmIdentifiers<'a> {
219
+ let digest_algorithm = DigestAlgorithmIdentifier {
220
+ oid: der::asn1::ObjectIdentifier::new(OID_ED25519).unwrap(),
221
+ parameters: None
222
+ };
223
+ let mut digest_algorithms = DigestAlgorithmIdentifiers::new();
224
+ digest_algorithms.add(digest_algorithm).unwrap();
225
+ digest_algorithms
226
+ }
227
+
228
+ fn get_encap_content_info<'a>() -> EncapsulatedContentInfo<'a> {
229
+ EncapsulatedContentInfo {
230
+ e_content_type: der::asn1::ObjectIdentifier::new(OID_PKCS7_SIGNED_DATA).unwrap(),
231
+ e_content: None,
232
+ }
233
+ }
234
+
235
+ fn get_certificates<'a>() -> Option<CertificateSet<'a>> {
236
+ None
237
+ }
238
+
239
+ fn get_signer_infos<'a>() -> SignerInfos<'a> {
240
+ let signer_infos = SignerInfos::new();
241
+ signer_infos
242
+ }
243
+
244
+
0 commit comments