Upgrade to latest version of rsa crate
This commit is contained in:
parent
0ffa58d2d4
commit
32ecff11eb
|
@ -82,12 +82,12 @@ impl PublicKey {
|
||||||
/// Return true iff the exponent for this key is the same
|
/// Return true iff the exponent for this key is the same
|
||||||
/// number as 'e'.
|
/// number as 'e'.
|
||||||
pub fn exponent_is(&self, e: u32) -> bool {
|
pub fn exponent_is(&self, e: u32) -> bool {
|
||||||
use rsa::PublicKey;
|
use rsa::PublicKeyParts;
|
||||||
*self.0.e() == rsa::BigUint::new(vec![e])
|
*self.0.e() == rsa::BigUint::new(vec![e])
|
||||||
}
|
}
|
||||||
/// Return the number of bits in the modulus for this key.
|
/// Return the number of bits in the modulus for this key.
|
||||||
pub fn bits(&self) -> usize {
|
pub fn bits(&self) -> usize {
|
||||||
use rsa::PublicKey;
|
use rsa::PublicKeyParts;
|
||||||
self.0.n().bits()
|
self.0.n().bits()
|
||||||
}
|
}
|
||||||
/// Try to check a signature (as used in Tor.) The signed hash
|
/// Try to check a signature (as used in Tor.) The signed hash
|
||||||
|
@ -102,8 +102,8 @@ impl PublicKey {
|
||||||
///
|
///
|
||||||
pub fn verify(&self, hashed: &[u8], sig: &[u8]) -> rsa::errors::Result<()> {
|
pub fn verify(&self, hashed: &[u8], sig: &[u8]) -> rsa::errors::Result<()> {
|
||||||
use rsa::PublicKey;
|
use rsa::PublicKey;
|
||||||
self.0
|
let padding = rsa::PaddingScheme::new_pkcs1v15_sign(None);
|
||||||
.verify::<rsa::hash::Hashes>(rsa::PaddingScheme::PKCS1v15, None, hashed, sig)
|
self.0.verify(padding, hashed, sig)
|
||||||
}
|
}
|
||||||
/// Decode an alleged DER byte string into a PublicKey.
|
/// Decode an alleged DER byte string into a PublicKey.
|
||||||
///
|
///
|
||||||
|
@ -150,15 +150,15 @@ impl PublicKey {
|
||||||
///
|
///
|
||||||
/// The result is an RSAPublicKey, not a PublicKeyInfo.
|
/// The result is an RSAPublicKey, not a PublicKeyInfo.
|
||||||
pub fn to_der(&self) -> Vec<u8> {
|
pub fn to_der(&self) -> Vec<u8> {
|
||||||
use simple_asn1::ASN1Block;
|
// There seem to be version issues with these two versions of
|
||||||
// XXX do I really need both of these crates? rsa uses
|
// bigint. XXXX
|
||||||
// bigint_dig, and simple_asn1 uses bigint.
|
use rsa::BigUint; // not the same as the one in simple_asn1.
|
||||||
use num_bigint::{BigInt, Sign};
|
use rsa::PublicKeyParts;
|
||||||
use rsa::BigUint; // not the same as the one in num_bigint.
|
use simple_asn1::{ASN1Block, BigInt};
|
||||||
use rsa::PublicKey;
|
|
||||||
fn to_asn1_int(x: &BigUint) -> ASN1Block {
|
fn to_asn1_int(x: &BigUint) -> ASN1Block {
|
||||||
let bytes = x.to_bytes_be();
|
let mut bytes = vec![0];
|
||||||
let bigint = BigInt::from_bytes_be(Sign::Plus, &bytes);
|
bytes.extend(x.to_bytes_be());
|
||||||
|
let bigint = BigInt::from_signed_bytes_be(&bytes);
|
||||||
ASN1Block::Integer(0, bigint)
|
ASN1Block::Integer(0, bigint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue