Improve types and documentation

This commit is contained in:
dAxpeDDa
2021-07-30 14:45:27 -07:00
committed by Kevin Lewi
parent 3f6b6d4afe
commit a5b9330b63
2 changed files with 9 additions and 8 deletions
+6 -6
View File
@@ -122,24 +122,24 @@ pub(crate) struct OpenedInnerEnvelope<D: Hash> {
}
#[cfg(not(test))]
type SealRaw<CS> = (
type SealRawResult<CS> = (
Envelope<CS>,
GenericArray<u8, <<CS as CipherSuite>::Hash as Digest>::OutputSize>,
);
#[cfg(test)]
type SealRaw<CS> = (
type SealRawResult<CS> = (
Envelope<CS>,
GenericArray<u8, <<CS as CipherSuite>::Hash as Digest>::OutputSize>,
Vec<u8>,
);
#[cfg(not(test))]
type Seal<CS> = (
type SealResult<CS> = (
Envelope<CS>,
PublicKey<<CS as CipherSuite>::Group>,
GenericArray<u8, <<CS as CipherSuite>::Hash as Digest>::OutputSize>,
);
#[cfg(test)]
type Seal<CS> = (
type SealResult<CS> = (
Envelope<CS>,
PublicKey<<CS as CipherSuite>::Group>,
GenericArray<u8, <<CS as CipherSuite>::Hash as Digest>::OutputSize>,
@@ -207,7 +207,7 @@ impl<CS: CipherSuite> Envelope<CS> {
key: &[u8],
server_s_pk: &[u8],
optional_ids: Option<Identifiers>,
) -> Result<Seal<CS>, ProtocolError> {
) -> Result<SealResult<CS>, ProtocolError> {
let mut nonce = vec![0u8; NONCE_LEN];
rng.fill_bytes(&mut nonce);
@@ -238,7 +238,7 @@ impl<CS: CipherSuite> Envelope<CS> {
nonce: &[u8],
aad: &[u8],
mode: InnerEnvelopeMode,
) -> Result<SealRaw<CS>, InternalPakeError> {
) -> Result<SealRawResult<CS>, InternalPakeError> {
let h = Hkdf::<CS::Hash>::new(None, key);
let mut hmac_key = vec![0u8; Self::hmac_key_size()];
let mut export_key = vec![0u8; Self::export_key_size()];
+3 -2
View File
@@ -573,7 +573,7 @@ pub struct ClientLoginFinishResult<CS: CipherSuite> {
/// Instance of the ClientLogin, only used in tests for checking zeroize
#[cfg(test)]
pub state: ClientLogin<CS>,
/// Handshake secret, only used tests
/// Handshake secret, only used in tests
#[cfg(test)]
pub handshake_secret: Vec<u8>,
/// Client MAC key, only used in tests
@@ -752,9 +752,10 @@ pub struct ServerLoginStartResult<CS: CipherSuite> {
pub message: CredentialResponse<CS>,
/// The state that the server must keep in order to finish the protocl
pub state: ServerLogin<CS>,
/// Handshake secret, only used tests
/// Handshake secret, only used in tests
#[cfg(test)]
pub handshake_secret: Vec<u8>,
/// Server MAC key, only used in tests
#[cfg(test)]
pub server_mac_key: GenericArray<u8, <CS::Hash as Digest>::OutputSize>,
}