///|
fn hex_of(bytes : Bytes) -> String {
let buf = StringBuilder()
for i in 0.. abort("failed to parse fixture certificate")
}
let (modulus, _) = match cert.rsa_public_key() {
Some(pair) => pair
None => abort("fixture has no RSA key")
}
let attrs = @cms.build_signed_attrs(
@oids.id_data,
digest,
Some(1793793600L),
cert,
@crypto.Hash::Sha256,
)
let signature = @crypto.sign_rsa_pkcs1(
@crypto.Hash::Sha256,
attrs,
modulus,
@fixtures.bytes_of_hex(@fixtures.rsa_d_hex),
) catch {
_ => abort("RSA signing failed")
}
let cms_bytes = @cms.assemble_signed_data(
attrs,
signature,
@crypto.Hash::Sha256,
@oids.sha256_with_rsa,
cert,
[],
@oids.id_data,
)
println("HEX:" + hex_of(cms_bytes))
}