blob: 79497a66305eecf9eec1868884e9bec48055302d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
//! Implementation of Sequoia crypto API using the Nettle cryptographic library.
use crate::types::*;
use nettle::random::{Random, Yarrow};
pub mod aead;
pub mod asymmetric;
pub mod ecdh;
pub mod hash;
pub mod symmetric;
/// Fills the given buffer with random data.
pub fn random(buf: &mut [u8]) {
Yarrow::default().random(buf);
}
impl PublicKeyAlgorithm {
pub(crate) fn is_supported_by_backend(&self) -> bool {
use PublicKeyAlgorithm::*;
#[allow(deprecated)]
match &self {
RSAEncryptSign | RSAEncrypt | RSASign | DSA | ECDH | ECDSA | EdDSA
=> true,
ElGamalEncrypt | ElGamalEncryptSign | Private(_) | Unknown(_)
=> false,
}
}
}
impl Curve {
pub(crate) fn is_supported_by_backend(&self) -> bool {
use self::Curve::*;
match &self {
NistP256 | NistP384 | NistP521 | Ed25519 | Cv25519
=> true,
BrainpoolP256 | BrainpoolP512 | Unknown(_)
=> false,
}
}
}
impl AEADAlgorithm {
pub(crate) fn is_supported_by_backend(&self) -> bool {
use self::AEADAlgorithm::*;
match &self {
EAX
=> true,
OCB | Private(_) | Unknown(_)
=> false,
}
}
}
|