feat: parse pgp cert works
This commit is contained in:
10
src/fido.rs
10
src/fido.rs
@@ -94,9 +94,9 @@ impl U2fV2Challenge {
|
||||
pub fn new_random<S>(app_id: S) -> Self where S: Into<String> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rand_bytes = [0_u8; 32];
|
||||
for i in 0..32 {
|
||||
for c in &mut rand_bytes {
|
||||
let b: u8 = rng.gen();
|
||||
rand_bytes[i] = b;
|
||||
*c = b;
|
||||
}
|
||||
|
||||
let challenge = base64::encode_config(&rand_bytes, URL_SAFE_NO_PAD);
|
||||
@@ -143,11 +143,11 @@ pub fn to_pem(bs: &[u8], sub: &str, w: usize) -> String {
|
||||
s.push_str(&format!("-----BEGIN {}-----", sub));
|
||||
let b64 = base64::encode(bs).chars().collect::<Vec<char>>();
|
||||
let mut b64 = b64.as_slice();
|
||||
while b64.len() > 0 {
|
||||
while !b64.is_empty() {
|
||||
s.push('\n');
|
||||
if b64.len() >= w {
|
||||
for i in 0..w {
|
||||
s.push(b64[i]);
|
||||
for c in b64.iter().take(w) {
|
||||
s.push(*c);
|
||||
}
|
||||
b64 = &b64[w..];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user