Hi there,
I'm quite new on rust and need some help on the following problem:
- I use an algorithm for generating a DSA-signature in a distributed manner. That means several participants generate the DSA-signature without any of them knowing the secret key for signature generation. For more info how this works read https://eprint.iacr.org/2019/114.pdf but it is actually not required to know this.
- I generated an X509 certificate and imported it to rust using the openssl crate (version 0.10.0)
- Now I want to replace the signature value in this X509 certificate with the signature value calculated in step one. As far as I understood, the openssl crate does not provide a method for doing this. Furthermore the datatype Asn1BitString turns out to be a bit tricky.
Does anybody know how I could replace the signature value in the X509-certificate with the one I calculated?
My code looks more or less like this at the moment but obviously doesn't change the signature value at all. All I could achieve was printing the current signature value stored in the imported certificate.
pub fn modcert() -> io::Result<()> {
//get file contents to Vector
let mut f = File::open("dsacert.pem")?;
let mut buffervec = Vec::new();
f.read_to_end(&mut buffervec)?;
//Convert Vector to Bytes
let buffer = buffervec;
//read certificate contents to a X509 struct
let res = X509::from_pem(&buffer);
let res = match res {
Ok(result) => result,
Err(error) => {
panic!("Problem reading the file: {:?}", error)
},
};
//Print Signature
let sign = res.signature(); //type: Asn1BitString
let sign_alg = res.signature_algorithm();
let sign_vec = sign.as_slice(); //type: &[u8]
let sign_len = sign.len(); //type: usize
println!("{:?}", (sign_vec, sign_len));
Ok(())
}
fn main() {
let r = modcert();
}