|
1 | 1 | // SPDX-License-Identifier: Apache-2.0
|
2 | 2 | // Copyright 2021 Keylime Authors
|
3 | 3 |
|
4 |
| -use crate::error::{Error, Result}; |
5 |
| -use crate::permissions; |
| 4 | +use crate::{ |
| 5 | + crypto::{AES_128_KEY_LEN, AES_256_KEY_LEN}, |
| 6 | + error::{Error, Result}, |
| 7 | + permissions, |
| 8 | +}; |
| 9 | + |
6 | 10 | use keylime::algorithms::{
|
7 | 11 | EncryptionAlgorithm, HashAlgorithm, SignAlgorithm,
|
8 | 12 | };
|
@@ -42,9 +46,6 @@ pub static RSA_PUBLICKEY_EXPORTABLE: &str = "rsa placeholder";
|
42 | 46 | pub static KEY: &str = "secret";
|
43 | 47 | pub const AGENT_UUID_LEN: usize = 36;
|
44 | 48 | pub const AUTH_TAG_LEN: usize = 48;
|
45 |
| -pub const AES_128_KEY_LEN: usize = 16; |
46 |
| -pub const AES_256_KEY_LEN: usize = 32; |
47 |
| -pub const AES_BLOCK_SIZE: usize = 16; |
48 | 49 |
|
49 | 50 | #[derive(Serialize, Deserialize, Debug)]
|
50 | 51 | pub(crate) struct APIVersion {
|
@@ -253,14 +254,9 @@ impl AgentData {
|
253 | 254 | ///
|
254 | 255 | /// This is used as the agent UUID when the configuration option 'uuid' is set as 'hash_ek'
|
255 | 256 | pub(crate) fn hash_ek_pubkey(ek_pub: Public) -> Result<String> {
|
256 |
| - // Converting Public TPM key to PEM |
257 |
| - let key = SubjectPublicKeyInfo::try_from(ek_pub)?; |
258 |
| - let key_der = picky_asn1_der::to_vec(&key)?; |
259 |
| - let openssl_key = PKey::public_key_from_der(&key_der)?; |
260 |
| - let pem = openssl_key.public_key_to_pem()?; |
261 |
| - |
262 | 257 | // Calculate the SHA-256 hash of the public key in PEM format
|
263 |
| - let mut hash = hash(MessageDigest::sha256(), &pem)?; |
| 258 | + let pem = crate::crypto::tss_pubkey_to_pem(ek_pub)?; |
| 259 | + let hash = crate::crypto::hash(&pem, MessageDigest::sha256())?; |
264 | 260 | Ok(hex::encode(hash))
|
265 | 261 | }
|
266 | 262 |
|
|
0 commit comments