Skip to content

Commit c672a5a

Browse files
AureliaDoloFirelightFlagboy
authored andcommitted
Rename EncryptionAlgorithm to PKIEncryptionAlgorithm.
1 parent ce944b3 commit c672a5a

File tree

12 files changed

+33
-31
lines changed

12 files changed

+33
-31
lines changed

libparsec/crates/platform_device_loader/tests/units/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async fn list_devices(tmp_path: TmpPath) {
173173
.add_or_replace_uri(X509WindowsCngURI::from(Bytes::from_static(
174174
b"Mallory's certificate",
175175
))),
176-
algorithm_for_encrypted_key: EncryptionAlgorithm::RsaesOaepSha256,
176+
algorithm_for_encrypted_key: PKIEncryptionAlgorithm::RsaesOaepSha256,
177177
encrypted_key: hex!("de5c59cfcc0c52bf997594e0fdd2c24ffee9465b6f25e30bac9238c2f83fd19a")
178178
.as_ref()
179179
.into(),

libparsec/crates/platform_device_loader/tests/units/pki/save.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn ok_simple(tmp_path: TmpPath, env: &TestbedEnv) {
3333
human_handle: alice_device.human_handle.clone(),
3434
},
3535
encrypted_key: Bytes::from_static(b"encrypted key"),
36-
encrypted_key_algo: libparsec_types::EncryptionAlgorithm::RsaesOaepSha256,
36+
encrypted_key_algo: libparsec_types::PKIEncryptionAlgorithm::RsaesOaepSha256,
3737
ciphertext: Bytes::from_static(b"encrypted secret part"),
3838
};
3939
save_pki_local_pending(local_pending, path).await.unwrap();

libparsec/crates/platform_pki/examples/decrypt_message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod utils;
66
use anyhow::Context;
77
use clap::Parser;
88
use libparsec_platform_pki::decrypt_message;
9-
use libparsec_types::{EncryptionAlgorithm, X509CertificateHash};
9+
use libparsec_types::{PKIEncryptionAlgorithm, X509CertificateHash};
1010

1111
#[derive(Debug, Parser)]
1212
struct Args {
@@ -16,8 +16,8 @@ struct Args {
1616
#[command(flatten)]
1717
content: utils::ContentOpts,
1818
/// The algorithm used to encrypt the content.
19-
#[arg(long, default_value_t = EncryptionAlgorithm::RsaesOaepSha256)]
20-
algorithm: EncryptionAlgorithm,
19+
#[arg(long, default_value_t = PKIEncryptionAlgorithm::RsaesOaepSha256)]
20+
algorithm: PKIEncryptionAlgorithm,
2121
}
2222

2323
fn main() -> anyhow::Result<()> {

libparsec/crates/platform_pki/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod x509;
1010
#[path = "../tests/units/mod.rs"]
1111
mod test;
1212

13-
use libparsec_types::{EncryptionAlgorithm, PkiSignatureAlgorithm, X509CertificateReference};
13+
use libparsec_types::{PKIEncryptionAlgorithm, PkiSignatureAlgorithm, X509CertificateReference};
1414

1515
use bytes::Bytes;
1616

@@ -25,7 +25,7 @@ mod platform {
2525
DecryptedMessage, EncryptMessageError, EncryptedMessage, GetDerEncodedCertificateError,
2626
ShowCertificateSelectionDialogError, SignMessageError, SignedMessageFromPki,
2727
};
28-
use libparsec_types::{EncryptionAlgorithm, X509CertificateReference};
28+
use libparsec_types::{PKIEncryptionAlgorithm, X509CertificateReference};
2929

3030
pub fn get_der_encoded_certificate(
3131
certificate_ref: &X509CertificateReference,
@@ -57,7 +57,7 @@ mod platform {
5757
}
5858

5959
pub fn decrypt_message(
60-
algo: EncryptionAlgorithm,
60+
algo: PKIEncryptionAlgorithm,
6161
encrypted_message: &[u8],
6262
certificate_ref: &X509CertificateReference,
6363
) -> Result<DecryptedMessage, DecryptMessageError> {
@@ -125,7 +125,7 @@ pub use platform::sign_message;
125125
pub use shared::{verify_message, Certificate, SignedMessage};
126126

127127
pub struct EncryptedMessage {
128-
pub algo: EncryptionAlgorithm,
128+
pub algo: PKIEncryptionAlgorithm,
129129
pub cert_ref: X509CertificateReference,
130130
pub ciphered: Bytes,
131131
}

libparsec/crates/platform_pki/src/windows/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010
use bytes::Bytes;
1111
use libparsec_types::{
12-
EncryptionAlgorithm, PkiSignatureAlgorithm, X509CertificateHash, X509CertificateReference,
12+
PKIEncryptionAlgorithm, PkiSignatureAlgorithm, X509CertificateHash, X509CertificateReference,
1313
X509WindowsCngURI,
1414
};
1515
use schannel::{
@@ -352,8 +352,8 @@ pub fn encrypt_message(
352352
fn ncrypt_encrypt_message_with_rsa(
353353
message: &[u8],
354354
handle: &NcryptKey,
355-
) -> std::io::Result<(EncryptionAlgorithm, Vec<u8>)> {
356-
const ALGO: EncryptionAlgorithm = EncryptionAlgorithm::RsaesOaepSha256;
355+
) -> std::io::Result<(PKIEncryptionAlgorithm, Vec<u8>)> {
356+
const ALGO: PKIEncryptionAlgorithm = PKIEncryptionAlgorithm::RsaesOaepSha256;
357357
// SAFETY: NcryptKey is obtain from an NCRYPT_KEY_HANDLE, here we retrieve the underlying
358358
// handle.
359359
let raw_handle = unsafe { RawPointer::as_ptr(handle) } as NCRYPT_KEY_HANDLE;
@@ -413,7 +413,7 @@ fn ncrypt_encrypt_message_with_rsa(
413413
}
414414

415415
pub fn decrypt_message(
416-
algo: EncryptionAlgorithm,
416+
algo: PKIEncryptionAlgorithm,
417417
encrypted_message: &[u8],
418418
certificate_ref: &X509CertificateReference,
419419
) -> Result<DecryptedMessage, DecryptMessageError> {
@@ -430,7 +430,7 @@ pub fn decrypt_message(
430430
}
431431
// Handle to a CryptoGraphy Next Generation (CNG) API
432432
PrivateKey::NcryptKey(handle) => {
433-
if algo != EncryptionAlgorithm::RsaesOaepSha256 {
433+
if algo != PKIEncryptionAlgorithm::RsaesOaepSha256 {
434434
todo!("Unsupported encryption algo '{algo}'");
435435
}
436436
ncrypt_decrypt_message_with_rsa(encrypted_message, &handle).map(Into::into)

libparsec/crates/serialization_format/src/protocol_python_bindings.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,9 @@ fn quote_type_as_fn_getter_conversion(field_path: &TokenStream, ty: &FieldType)
944944
FieldType::X509CertificateReference => {
945945
quote_rs_to_py_class!(crate::data::X509CertificateReference)
946946
}
947-
FieldType::EncryptionAlgorithm => quote_rs_to_py_class!(crate::data::EncryptionAlgorithm),
947+
FieldType::PKIEncryptionAlgorithm => {
948+
quote_rs_to_py_class!(crate::data::PKIEncryptionAlgorithm)
949+
}
948950
FieldType::PkiSignatureAlgorithm => {
949951
quote_rs_to_py_class!(crate::data::PkiSignatureAlgorithm)
950952
}
@@ -1047,7 +1049,7 @@ fn quote_type_as_fn_new_param(ty: &FieldType) -> TokenStream {
10471049
FieldType::PkiEnrollmentSubmitPayload => quote! { crate::data::PkiEnrollmentSubmitPayload },
10481050
FieldType::X509Certificate => quote! { crate::data::X509Certificate },
10491051
FieldType::X509CertificateReference => quote! { crate::data::X509CertificateReference },
1050-
FieldType::EncryptionAlgorithm => quote! { crate::data::EncryptionAlgorithm },
1052+
FieldType::PKIEncryptionAlgorithm => quote! { crate::data::PKIEncryptionAlgorithm },
10511053
FieldType::PkiSignatureAlgorithm => quote! { crate::data::PkiSignatureAlgorithm },
10521054
FieldType::ShamirRecoveryShareData => {
10531055
quote! { crate::shamir::ShamirRecoveryShareData}
@@ -1194,7 +1196,7 @@ fn internal_quote_field_as_fn_new_conversion(field_name: &Ident, ty: &FieldType)
11941196
| FieldType::PkiEnrollmentSubmitPayload
11951197
| FieldType::X509Certificate
11961198
| FieldType::X509CertificateReference
1197-
| FieldType::EncryptionAlgorithm
1199+
| FieldType::PKIEncryptionAlgorithm
11981200
| FieldType::PkiSignatureAlgorithm
11991201
| FieldType::GreetingAttemptID
12001202
| FieldType::CancelledGreetingAttemptReason

libparsec/crates/serialization_format/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ generate_field_type_enum!(
257257
PkiEnrollmentSubmitPayload => PkiEnrollmentSubmitPayload,
258258
X509Certificate => libparsec_types::X509Certificate,
259259
X509CertificateReference => libparsec_types::X509CertificateReference,
260-
EncryptionAlgorithm => libparsec_types::EncryptionAlgorithm,
260+
PKIEncryptionAlgorithm => libparsec_types::PKIEncryptionAlgorithm,
261261
PkiSignatureAlgorithm => libparsec_types::PkiSignatureAlgorithm,
262262
GreetingAttemptID => libparsec_types::GreetingAttemptID,
263263
GreeterOrClaimer => libparsec_types::GreeterOrClaimer,

libparsec/crates/types/schema/pki/local_pending_enrollment.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"name": "encrypted_key_algo",
38-
"type": "EncryptionAlgorithm"
38+
"type": "PKIEncryptionAlgorithm"
3939
},
4040
{
4141
"name": "ciphertext",

libparsec/crates/types/src/local_device_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55

66
use libparsec_serialization_format::parsec_data;
77

8-
use crate::{self as libparsec_types, DataError, EncryptionAlgorithm, X509CertificateReference};
8+
use crate::{self as libparsec_types, DataError, PKIEncryptionAlgorithm, X509CertificateReference};
99
use crate::{
1010
impl_transparent_data_format_conversion, AccountVaultItemOpaqueKeyID, DateTime, DeviceID,
1111
DeviceLabel, HumanHandle, OrganizationID, PasswordAlgorithm, UserID,
@@ -119,7 +119,7 @@ pub struct DeviceFileSmartcard {
119119
pub human_handle: HumanHandle,
120120
pub device_label: DeviceLabel,
121121
pub certificate_ref: X509CertificateReference,
122-
pub algorithm_for_encrypted_key: EncryptionAlgorithm,
122+
pub algorithm_for_encrypted_key: PKIEncryptionAlgorithm,
123123
pub encrypted_key: Bytes,
124124
pub ciphertext: Bytes,
125125
}

libparsec/crates/types/src/pki/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub struct PKILocalPendingEnrollment {
150150
pub enrollment_id: PKIEnrollmentID,
151151
pub payload: PkiEnrollmentSubmitPayload,
152152
pub encrypted_key: Bytes,
153-
pub encrypted_key_algo: EncryptionAlgorithm,
153+
pub encrypted_key_algo: PKIEncryptionAlgorithm,
154154
pub ciphertext: Bytes,
155155
}
156156

@@ -225,19 +225,19 @@ impl PrivateParts {
225225
#[derive(
226226
Debug, Clone, Copy, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay,
227227
)]
228-
pub enum EncryptionAlgorithm {
228+
pub enum PKIEncryptionAlgorithm {
229229
RsaesOaepSha256,
230230
}
231231

232-
impl From<EncryptionAlgorithm> for &'static str {
233-
fn from(value: EncryptionAlgorithm) -> Self {
232+
impl From<PKIEncryptionAlgorithm> for &'static str {
233+
fn from(value: PKIEncryptionAlgorithm) -> Self {
234234
match value {
235-
EncryptionAlgorithm::RsaesOaepSha256 => "RSAES-OAEP-SHA256",
235+
PKIEncryptionAlgorithm::RsaesOaepSha256 => "RSAES-OAEP-SHA256",
236236
}
237237
}
238238
}
239239

240-
impl FromStr for EncryptionAlgorithm {
240+
impl FromStr for PKIEncryptionAlgorithm {
241241
type Err = &'static str;
242242

243243
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -248,7 +248,7 @@ impl FromStr for EncryptionAlgorithm {
248248
}
249249
}
250250

251-
impl Display for EncryptionAlgorithm {
251+
impl Display for PKIEncryptionAlgorithm {
252252
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
253253
f.write_str((*self).into())
254254
}

0 commit comments

Comments
 (0)