Skip to content

Commit c669234

Browse files
committed
feat(E2EE-2407): Add support of PrehashedAndEncryptedPassphrase in Enroll API
1 parent 1dbbbf4 commit c669234

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/verification.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::ctanker::{
44
};
55
use std::ffi::CString;
66

7-
const CVERIFICATION_VERSION: u8 = 8;
7+
const CVERIFICATION_VERSION: u8 = 9;
88
const CEMAIL_VERIFICATION_VERSION: u8 = 1;
99
const CPHONE_NUMBER_VERIFICATION_VERSION: u8 = 1;
1010
const CPREVERIFIED_OIDC_VERIFICATION_VERSION: u8 = 1;
@@ -23,6 +23,7 @@ enum Type {
2323
E2ePassphrase = 8,
2424
PreverifiedOIDC = 9,
2525
OIDCAuthorizationCode = 10,
26+
PrehashedAndEncryptedPassphrase = 11,
2627
}
2728

2829
pub(crate) struct CVerificationWrapper {
@@ -68,6 +69,7 @@ impl CVerificationWrapper {
6869
authorization_code: std::ptr::null(),
6970
state: std::ptr::null(),
7071
},
72+
prehashed_and_encrypted_passphrase: std::ptr::null(),
7173
},
7274
}
7375
}
@@ -166,6 +168,19 @@ impl CVerificationWrapper {
166168
wrapper
167169
}
168170

171+
pub(self) fn with_prehashed_and_encrypted_passphrase(
172+
prehashed_and_encrypted_passphrase: &str,
173+
) -> Self {
174+
let mut wrapper = Self::new();
175+
let cpaep = CString::new(prehashed_and_encrypted_passphrase).unwrap();
176+
177+
wrapper.cverif.verification_method_type = Type::PrehashedAndEncryptedPassphrase as u8;
178+
wrapper.cverif.prehashed_and_encrypted_passphrase = cpaep.as_ptr();
179+
180+
wrapper.cstrings.push(cpaep);
181+
wrapper
182+
}
183+
169184
pub(self) fn with_preverifed_oidc(subject: &str, provider_id: &str) -> Self {
170185
let mut wrapper = Self::new();
171186
let csubject = CString::new(subject).unwrap();
@@ -240,6 +255,7 @@ pub enum Verification {
240255
authorization_code: String,
241256
state: String,
242257
},
258+
PrehashedAndEncryptedPassphrase(String),
243259
}
244260

245261
impl Verification {
@@ -281,6 +297,11 @@ impl Verification {
281297
authorization_code,
282298
state,
283299
),
300+
Verification::PrehashedAndEncryptedPassphrase(prehashed_and_encrypted_passphrase) => {
301+
CVerificationWrapper::with_prehashed_and_encrypted_passphrase(
302+
prehashed_and_encrypted_passphrase,
303+
)
304+
}
284305
}
285306
}
286307
}

src/verification_methods.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum VerificationMethod {
2525
E2ePassphrase,
2626
// PreverifiedOIDC is not exposed as a VerificationMethod
2727
// OIDCAuthorizationCode is not exposed as a VerificationMethod
28+
// PrehashedAndEncryptedPassphrase is not exposed as a VerificationMethod
2829
}
2930

3031
#[derive(FromPrimitive)]
@@ -42,6 +43,7 @@ enum CMethodType {
4243
E2ePassphrase = 8,
4344
// PreverifiedOIDC = 9, PreverifiedOIDC is not exposed as a VerificationMethod
4445
// OIDCAuthorizationCode = 10, OIDCAuthorizationCode is not exposed as a VerificationMethod
46+
// PrehashedAndEncryptedPassphrase = 11, PrehashedAndEncryptedPassphraseis not exposed as a VerificationMethod
4547
#[num_enum(default)]
4648
Invalid,
4749
}

0 commit comments

Comments
 (0)