From 679c76ccb3273ea41499906f2b8c7908d24b7507 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 6 Nov 2018 01:14:30 +0100 Subject: aquatic-prime: Strip `0x` from public & private keys Learned from: https://github.com/bdrister/AquaticPrime/blob/57c6f70/Source/Cocoa/AquaticPrime.m#L111-L114 that the "0x" prefix on the hex keys needs to be removed before using the RSA library functions on it. Otherwise it doesn't work. Couldn't figure that out from the other implementations because they use custom conversion functions instead of OpenSSL's functions. Previously, calling `BigNum::from_hex_str()` on the strings would yield `0`, but now we get proper BigNums. --- license-generator/aquatic-prime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/license-generator/aquatic-prime/src/lib.rs b/license-generator/aquatic-prime/src/lib.rs index 80db363..15c4aea 100644 --- a/license-generator/aquatic-prime/src/lib.rs +++ b/license-generator/aquatic-prime/src/lib.rs @@ -28,8 +28,8 @@ impl<'a> AquaticPrime<'a> { .collect::>() .concat(); - let public_key = BigNum::from_hex_str(self.public_key).unwrap(); - let private_key = BigNum::from_hex_str(self.private_key).unwrap(); + let public_key = BigNum::from_hex_str(self.public_key.get(2..).unwrap()).unwrap(); + let private_key = BigNum::from_hex_str(self.private_key.get(2..).unwrap()).unwrap(); let rsa_e = BigNum::from_u32(3).unwrap(); if public_key.num_bits() != 1024 { -- cgit v1.2.3