Skip to content

Commit 267fcc2

Browse files
committed
Fix
1 parent 171dccb commit 267fcc2

1 file changed

Lines changed: 0 additions & 81 deletions

File tree

src/aead.rs

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -511,87 +511,6 @@ mod recprot {
511511
}
512512
}
513513

514-
#[cfg(test)]
515-
#[cfg_attr(coverage_nightly, coverage(off))]
516-
mod blapi_diag {
517-
use std::os::raw::c_uint;
518-
519-
use super::{
520-
super::super::{NONCE_LEN, TAG_LEN},
521-
GCM_PARAMS_LEN_C, NONCE_LEN_UL, TAG_BITS_UL,
522-
};
523-
use crate::freebl::{self, AesCtx};
524-
525-
#[test]
526-
fn aes_gcm_roundtrip() {
527-
test_fixture::fixture_init();
528-
let key = [0x42u8; 16];
529-
let make_ctx = |encrypt| unsafe {
530-
AesCtx::from_ptr(freebl::AES_CreateContext(
531-
key.as_ptr(),
532-
std::ptr::null(),
533-
freebl::NSS_AES_GCM,
534-
encrypt,
535-
16,
536-
16,
537-
))
538-
};
539-
let ctx_enc = make_ctx(1).expect("AES_CreateContext(encrypt)");
540-
let ctx_dec = make_ctx(0).expect("AES_CreateContext(decrypt)");
541-
542-
let nonce = [0u8; NONCE_LEN];
543-
let aad = b"hello";
544-
let plaintext = b"world123";
545-
let mut ciphertext = [0u8; 8];
546-
let mut tag = [0u8; TAG_LEN];
547-
let mut out_len: c_uint = 0;
548-
549-
let mut enc_params = freebl::CK_GCM_MESSAGE_PARAMS {
550-
pIv: nonce.as_ptr().cast_mut(),
551-
ulIvLen: NONCE_LEN_UL,
552-
ulIvFixedBits: 0,
553-
ivGenerator: 0,
554-
pTag: tag.as_mut_ptr(),
555-
ulTagBits: TAG_BITS_UL,
556-
};
557-
let rv = unsafe {
558-
freebl::AES_AEAD(
559-
*ctx_enc,
560-
ciphertext.as_mut_ptr(),
561-
&raw mut out_len,
562-
c_uint::try_from(ciphertext.len()).unwrap(),
563-
plaintext.as_ptr(),
564-
c_uint::try_from(plaintext.len()).unwrap(),
565-
(&raw mut enc_params).cast(),
566-
GCM_PARAMS_LEN_C,
567-
aad.as_ptr(),
568-
c_uint::try_from(aad.len()).unwrap(),
569-
)
570-
};
571-
assert_eq!(rv, 0, "AES_AEAD(encrypt) failed");
572-
assert_eq!(out_len as usize, plaintext.len());
573-
574-
let mut decrypted = [0u8; 8];
575-
let mut dec_out_len: c_uint = 0;
576-
let mut dec_params = enc_params;
577-
let rv_dec = unsafe {
578-
freebl::AES_AEAD(
579-
*ctx_dec,
580-
decrypted.as_mut_ptr(),
581-
&raw mut dec_out_len,
582-
c_uint::try_from(decrypted.len()).unwrap(),
583-
ciphertext.as_ptr(),
584-
c_uint::try_from(ciphertext.len()).unwrap(),
585-
(&raw mut dec_params).cast(),
586-
GCM_PARAMS_LEN_C,
587-
aad.as_ptr(),
588-
c_uint::try_from(aad.len()).unwrap(),
589-
)
590-
};
591-
assert_eq!(rv_dec, 0, "AES_AEAD(decrypt) failed");
592-
assert_eq!(decrypted, *plaintext);
593-
}
594-
}
595514
}
596515

597516
#[cfg(not(feature = "blapi"))]

0 commit comments

Comments
 (0)