clippy: *::max_value() -> *::MAX

This commit is contained in:
Rushil Mehra 2024-06-18 14:12:59 -07:00 committed by Alessandro Ghedini
parent 884c91e770
commit 924f452130
14 changed files with 43 additions and 43 deletions

View File

@ -58,7 +58,7 @@ impl AesKey {
#[allow(deprecated)] // https://github.com/rust-lang/rust/issues/63566 #[allow(deprecated)] // https://github.com/rust-lang/rust/issues/63566
pub fn new_encrypt(key: &[u8]) -> Result<AesKey, KeyError> { pub fn new_encrypt(key: &[u8]) -> Result<AesKey, KeyError> {
unsafe { unsafe {
assert!(key.len() <= c_int::max_value() as usize / 8); assert!(key.len() <= c_int::MAX as usize / 8);
let mut aes_key = MaybeUninit::uninit(); let mut aes_key = MaybeUninit::uninit();
let r = ffi::AES_set_encrypt_key( let r = ffi::AES_set_encrypt_key(
@ -82,7 +82,7 @@ impl AesKey {
#[allow(deprecated)] // https://github.com/rust-lang/rust/issues/63566 #[allow(deprecated)] // https://github.com/rust-lang/rust/issues/63566
pub fn new_decrypt(key: &[u8]) -> Result<AesKey, KeyError> { pub fn new_decrypt(key: &[u8]) -> Result<AesKey, KeyError> {
unsafe { unsafe {
assert!(key.len() <= c_int::max_value() as usize / 8); assert!(key.len() <= c_int::MAX as usize / 8);
let mut aes_key = MaybeUninit::uninit(); let mut aes_key = MaybeUninit::uninit();
let r = ffi::AES_set_decrypt_key( let r = ffi::AES_set_decrypt_key(

View File

@ -14,7 +14,7 @@ use libc::c_int;
/// ///
/// [`EVP_EncodeBlock`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DecodeBlock.html /// [`EVP_EncodeBlock`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DecodeBlock.html
pub fn encode_block(src: &[u8]) -> String { pub fn encode_block(src: &[u8]) -> String {
assert!(src.len() <= c_int::max_value() as usize); assert!(src.len() <= c_int::MAX as usize);
let src_len = src.len(); let src_len = src.len();
let len = encoded_len(src_len).unwrap(); let len = encoded_len(src_len).unwrap();
@ -48,7 +48,7 @@ pub fn decode_block(src: &str) -> Result<Vec<u8>, ErrorStack> {
return Ok(vec![]); return Ok(vec![]);
} }
assert!(src.len() <= c_int::max_value() as usize); assert!(src.len() <= c_int::MAX as usize);
let src_len = src.len(); let src_len = src.len();
let len = decoded_len(src_len).unwrap(); let len = decoded_len(src_len).unwrap();

View File

@ -26,7 +26,7 @@ impl<'a> MemBioSlice<'a> {
ffi::init(); ffi::init();
assert!(buf.len() <= BufLen::max_value() as usize); assert!(buf.len() <= BufLen::MAX as usize);
let bio = unsafe { let bio = unsafe {
cvt_p(BIO_new_mem_buf( cvt_p(BIO_new_mem_buf(
buf.as_ptr() as *const _, buf.as_ptr() as *const _,

View File

@ -159,7 +159,7 @@ impl BigNumRef {
pub fn div_word(&mut self, w: u32) -> Result<u64, ErrorStack> { pub fn div_word(&mut self, w: u32) -> Result<u64, ErrorStack> {
unsafe { unsafe {
let r = ffi::BN_div_word(self.as_ptr(), w.into()); let r = ffi::BN_div_word(self.as_ptr(), w.into());
if r == ffi::BN_ULONG::max_value() { if r == ffi::BN_ULONG::MAX {
Err(ErrorStack::get()) Err(ErrorStack::get())
} else { } else {
Ok(r.into()) Ok(r.into())
@ -176,7 +176,7 @@ impl BigNumRef {
pub fn mod_word(&self, w: u32) -> Result<u64, ErrorStack> { pub fn mod_word(&self, w: u32) -> Result<u64, ErrorStack> {
unsafe { unsafe {
let r = ffi::BN_mod_word(self.as_ptr(), w.into()); let r = ffi::BN_mod_word(self.as_ptr(), w.into());
if r == ffi::BN_ULONG::max_value() { if r == ffi::BN_ULONG::MAX {
Err(ErrorStack::get()) Err(ErrorStack::get())
} else { } else {
Ok(r.into()) Ok(r.into())
@ -987,7 +987,7 @@ impl BigNum {
pub fn from_slice(n: &[u8]) -> Result<BigNum, ErrorStack> { pub fn from_slice(n: &[u8]) -> Result<BigNum, ErrorStack> {
unsafe { unsafe {
ffi::init(); ffi::init();
assert!(n.len() <= c_int::max_value() as usize); assert!(n.len() <= c_int::MAX as usize);
cvt_p(ffi::BN_bin2bn( cvt_p(ffi::BN_bin2bn(
n.as_ptr(), n.as_ptr(),
n.len() as size_t, n.len() as size_t,

View File

@ -35,7 +35,7 @@ impl EcdsaSig {
T: HasPrivate, T: HasPrivate,
{ {
unsafe { unsafe {
assert!(data.len() <= c_int::max_value() as usize); assert!(data.len() <= c_int::MAX as usize);
let sig = cvt_p(ffi::ECDSA_do_sign( let sig = cvt_p(ffi::ECDSA_do_sign(
data.as_ptr(), data.as_ptr(),
data.len() as size_t, data.len() as size_t,
@ -94,7 +94,7 @@ impl EcdsaSigRef {
T: HasPublic, T: HasPublic,
{ {
unsafe { unsafe {
assert!(data.len() <= c_int::max_value() as usize); assert!(data.len() <= c_int::MAX as usize);
cvt_n(ffi::ECDSA_do_verify( cvt_n(ffi::ECDSA_do_verify(
data.as_ptr(), data.as_ptr(),
data.len() as size_t, data.len() as size_t,

View File

@ -59,7 +59,7 @@ macro_rules! private_key_to_pem {
) -> Result<Vec<u8>, crate::error::ErrorStack> { ) -> Result<Vec<u8>, crate::error::ErrorStack> {
unsafe { unsafe {
let bio = crate::bio::MemBio::new()?; let bio = crate::bio::MemBio::new()?;
assert!(passphrase.len() <= ::libc::c_int::max_value() as usize); assert!(passphrase.len() <= ::libc::c_int::MAX as usize);
cvt($f(bio.as_ptr(), cvt($f(bio.as_ptr(),
self.as_ptr(), self.as_ptr(),
cipher.as_ptr(), cipher.as_ptr(),
@ -108,7 +108,7 @@ macro_rules! from_der {
pub fn $n(der: &[u8]) -> Result<$t, crate::error::ErrorStack> { pub fn $n(der: &[u8]) -> Result<$t, crate::error::ErrorStack> {
unsafe { unsafe {
crate::ffi::init(); crate::ffi::init();
let len = ::std::cmp::min(der.len(), <$len_ty>::max_value() as usize) as $len_ty; let len = ::std::cmp::min(der.len(), <$len_ty>::MAX as usize) as $len_ty;
crate::cvt_p($f(::std::ptr::null_mut(), &mut der.as_ptr(), len)) crate::cvt_p($f(::std::ptr::null_mut(), &mut der.as_ptr(), len))
.map(|p| ::foreign_types::ForeignType::from_ptr(p)) .map(|p| ::foreign_types::ForeignType::from_ptr(p))
} }

View File

@ -32,7 +32,7 @@ pub fn bytes_to_key(
count: u32, count: u32,
) -> Result<KeyIvPair, ErrorStack> { ) -> Result<KeyIvPair, ErrorStack> {
unsafe { unsafe {
assert!(data.len() <= c_int::max_value() as usize); assert!(data.len() <= c_int::MAX as usize);
let salt_ptr = match salt { let salt_ptr = match salt {
Some(salt) => { Some(salt) => {
pub const PKCS5_SALT_LEN: c_int = 8; pub const PKCS5_SALT_LEN: c_int = 8;
@ -90,9 +90,9 @@ pub fn pbkdf2_hmac(
key: &mut [u8], key: &mut [u8],
) -> Result<(), ErrorStack> { ) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(pass.len() <= c_int::max_value() as usize); assert!(pass.len() <= c_int::MAX as usize);
assert!(salt.len() <= c_int::max_value() as usize); assert!(salt.len() <= c_int::MAX as usize);
assert!(key.len() <= c_int::max_value() as usize); assert!(key.len() <= c_int::MAX as usize);
ffi::init(); ffi::init();
cvt(ffi::PKCS5_PBKDF2_HMAC( cvt(ffi::PKCS5_PBKDF2_HMAC(

View File

@ -411,7 +411,7 @@ impl PKey<Private> {
pub fn private_key_from_pkcs8(der: &[u8]) -> Result<PKey<Private>, ErrorStack> { pub fn private_key_from_pkcs8(der: &[u8]) -> Result<PKey<Private>, ErrorStack> {
unsafe { unsafe {
ffi::init(); ffi::init();
let len = der.len().min(c_long::max_value() as usize) as c_long; let len = der.len().min(c_long::MAX as usize) as c_long;
let p8inf = cvt_p(ffi::d2i_PKCS8_PRIV_KEY_INFO( let p8inf = cvt_p(ffi::d2i_PKCS8_PRIV_KEY_INFO(
ptr::null_mut(), ptr::null_mut(),
&mut der.as_ptr(), &mut der.as_ptr(),

View File

@ -35,7 +35,7 @@ use crate::error::ErrorStack;
pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> { pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
ffi::init(); ffi::init();
assert!(buf.len() <= c_int::max_value() as usize); assert!(buf.len() <= c_int::MAX as usize);
cvt(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len())).map(|_| ()) cvt(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len())).map(|_| ())
} }
} }

View File

@ -151,7 +151,7 @@ where
to: &mut [u8], to: &mut [u8],
padding: Padding, padding: Padding,
) -> Result<usize, ErrorStack> { ) -> Result<usize, ErrorStack> {
assert!(from.len() <= i32::max_value() as usize); assert!(from.len() <= i32::MAX as usize);
assert!(to.len() >= self.size() as usize); assert!(to.len() >= self.size() as usize);
unsafe { unsafe {
@ -178,7 +178,7 @@ where
to: &mut [u8], to: &mut [u8],
padding: Padding, padding: Padding,
) -> Result<usize, ErrorStack> { ) -> Result<usize, ErrorStack> {
assert!(from.len() <= i32::max_value() as usize); assert!(from.len() <= i32::MAX as usize);
assert!(to.len() >= self.size() as usize); assert!(to.len() >= self.size() as usize);
unsafe { unsafe {
@ -378,7 +378,7 @@ where
to: &mut [u8], to: &mut [u8],
padding: Padding, padding: Padding,
) -> Result<usize, ErrorStack> { ) -> Result<usize, ErrorStack> {
assert!(from.len() <= i32::max_value() as usize); assert!(from.len() <= i32::MAX as usize);
assert!(to.len() >= self.size() as usize); assert!(to.len() >= self.size() as usize);
unsafe { unsafe {
@ -404,7 +404,7 @@ where
to: &mut [u8], to: &mut [u8],
padding: Padding, padding: Padding,
) -> Result<usize, ErrorStack> { ) -> Result<usize, ErrorStack> {
assert!(from.len() <= i32::max_value() as usize); assert!(from.len() <= i32::MAX as usize);
assert!(to.len() >= self.size() as usize); assert!(to.len() >= self.size() as usize);
unsafe { unsafe {

View File

@ -84,7 +84,7 @@ pub unsafe extern "C" fn take_stream<S>(bio: *mut BIO) -> S {
} }
pub unsafe fn set_dtls_mtu_size<S>(bio: *mut BIO, mtu_size: usize) { pub unsafe fn set_dtls_mtu_size<S>(bio: *mut BIO, mtu_size: usize) {
if mtu_size as u64 > c_long::max_value() as u64 { if mtu_size as u64 > c_long::MAX as u64 {
panic!( panic!(
"Given MTU size {} can't be represented in a positive `c_long` range", "Given MTU size {} can't be represented in a positive `c_long` range",
mtu_size mtu_size

View File

@ -1174,7 +1174,7 @@ impl SslContextBuilder {
/// [`SSL_CTX_set_session_id_context`]: https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_id_context.html /// [`SSL_CTX_set_session_id_context`]: https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_session_id_context.html
pub fn set_session_id_context(&mut self, sid_ctx: &[u8]) -> Result<(), ErrorStack> { pub fn set_session_id_context(&mut self, sid_ctx: &[u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(sid_ctx.len() <= c_uint::max_value() as usize); assert!(sid_ctx.len() <= c_uint::MAX as usize);
cvt(ffi::SSL_CTX_set_session_id_context( cvt(ffi::SSL_CTX_set_session_id_context(
self.as_ptr(), self.as_ptr(),
sid_ctx.as_ptr(), sid_ctx.as_ptr(),
@ -1449,7 +1449,7 @@ impl SslContextBuilder {
unsafe { unsafe {
#[cfg_attr(not(feature = "fips"), allow(clippy::unnecessary_cast))] #[cfg_attr(not(feature = "fips"), allow(clippy::unnecessary_cast))]
{ {
assert!(protocols.len() <= ProtosLen::max_value() as usize); assert!(protocols.len() <= ProtosLen::MAX as usize);
} }
let r = ffi::SSL_CTX_set_alpn_protos( let r = ffi::SSL_CTX_set_alpn_protos(
self.as_ptr(), self.as_ptr(),
@ -2951,7 +2951,7 @@ impl SslRef {
unsafe { unsafe {
#[cfg_attr(not(feature = "fips"), allow(clippy::unnecessary_cast))] #[cfg_attr(not(feature = "fips"), allow(clippy::unnecessary_cast))]
{ {
assert!(protocols.len() <= ProtosLen::max_value() as usize); assert!(protocols.len() <= ProtosLen::MAX as usize);
} }
let r = ffi::SSL_set_alpn_protos( let r = ffi::SSL_set_alpn_protos(
self.as_ptr(), self.as_ptr(),
@ -3552,7 +3552,7 @@ impl SslRef {
/// [`SSL_set_tlsext_status_ocsp_resp`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_set_tlsext_status_type.html /// [`SSL_set_tlsext_status_ocsp_resp`]: https://www.openssl.org/docs/man1.0.2/ssl/SSL_set_tlsext_status_type.html
pub fn set_ocsp_status(&mut self, response: &[u8]) -> Result<(), ErrorStack> { pub fn set_ocsp_status(&mut self, response: &[u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(response.len() <= c_int::max_value() as usize); assert!(response.len() <= c_int::MAX as usize);
let p = cvt_p(ffi::OPENSSL_malloc(response.len() as _))?; let p = cvt_p(ffi::OPENSSL_malloc(response.len() as _))?;
ptr::copy_nonoverlapping(response.as_ptr(), p as *mut u8, response.len()); ptr::copy_nonoverlapping(response.as_ptr(), p as *mut u8, response.len());
cvt(ffi::SSL_set_tlsext_status_ocsp_resp( cvt(ffi::SSL_set_tlsext_status_ocsp_resp(
@ -3933,7 +3933,7 @@ impl<S: Read + Write> SslStream<S> {
return Ok(0); return Ok(0);
} }
let len = usize::min(c_int::max_value() as usize, buf.len()) as c_int; let len = usize::min(c_int::MAX as usize, buf.len()) as c_int;
let ret = unsafe { ffi::SSL_read(self.ssl().as_ptr(), buf.as_mut_ptr().cast(), len) }; let ret = unsafe { ffi::SSL_read(self.ssl().as_ptr(), buf.as_mut_ptr().cast(), len) };
if ret > 0 { if ret > 0 {
Ok(ret as usize) Ok(ret as usize)
@ -3955,7 +3955,7 @@ impl<S: Read + Write> SslStream<S> {
return Ok(0); return Ok(0);
} }
let len = usize::min(c_int::max_value() as usize, buf.len()) as c_int; let len = usize::min(c_int::MAX as usize, buf.len()) as c_int;
let ret = unsafe { ffi::SSL_write(self.ssl().as_ptr(), buf.as_ptr().cast(), len) }; let ret = unsafe { ffi::SSL_write(self.ssl().as_ptr(), buf.as_ptr().cast(), len) };
if ret > 0 { if ret > 0 {
Ok(ret as usize) Ok(ret as usize)

View File

@ -323,7 +323,7 @@ impl Crypter {
mode, mode,
))?; ))?;
assert!(key.len() <= c_int::max_value() as usize); assert!(key.len() <= c_int::MAX as usize);
cvt(ffi::EVP_CIPHER_CTX_set_key_length( cvt(ffi::EVP_CIPHER_CTX_set_key_length(
crypter.ctx, crypter.ctx,
key.len() as c_uint, key.len() as c_uint,
@ -333,7 +333,7 @@ impl Crypter {
let iv = match (iv, t.iv_len()) { let iv = match (iv, t.iv_len()) {
(Some(iv), Some(len)) => { (Some(iv), Some(len)) => {
if iv.len() != len { if iv.len() != len {
assert!(iv.len() <= c_int::max_value() as usize); assert!(iv.len() <= c_int::MAX as usize);
cvt(ffi::EVP_CIPHER_CTX_ctrl( cvt(ffi::EVP_CIPHER_CTX_ctrl(
crypter.ctx, crypter.ctx,
ffi::EVP_CTRL_GCM_SET_IVLEN, ffi::EVP_CTRL_GCM_SET_IVLEN,
@ -374,7 +374,7 @@ impl Crypter {
/// When decrypting cipher text using an AEAD cipher, this must be called before `finalize`. /// When decrypting cipher text using an AEAD cipher, this must be called before `finalize`.
pub fn set_tag(&mut self, tag: &[u8]) -> Result<(), ErrorStack> { pub fn set_tag(&mut self, tag: &[u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(tag.len() <= c_int::max_value() as usize); assert!(tag.len() <= c_int::MAX as usize);
// NB: this constant is actually more general than just GCM. // NB: this constant is actually more general than just GCM.
cvt(ffi::EVP_CIPHER_CTX_ctrl( cvt(ffi::EVP_CIPHER_CTX_ctrl(
self.ctx, self.ctx,
@ -392,7 +392,7 @@ impl Crypter {
/// to use a value different than the default 12 bytes. /// to use a value different than the default 12 bytes.
pub fn set_tag_len(&mut self, tag_len: usize) -> Result<(), ErrorStack> { pub fn set_tag_len(&mut self, tag_len: usize) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(tag_len <= c_int::max_value() as usize); assert!(tag_len <= c_int::MAX as usize);
// NB: this constant is actually more general than just GCM. // NB: this constant is actually more general than just GCM.
cvt(ffi::EVP_CIPHER_CTX_ctrl( cvt(ffi::EVP_CIPHER_CTX_ctrl(
self.ctx, self.ctx,
@ -410,7 +410,7 @@ impl Crypter {
/// CCM mode. /// CCM mode.
pub fn set_data_len(&mut self, data_len: usize) -> Result<(), ErrorStack> { pub fn set_data_len(&mut self, data_len: usize) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(data_len <= c_int::max_value() as usize); assert!(data_len <= c_int::MAX as usize);
let mut len = 0; let mut len = 0;
cvt(ffi::EVP_CipherUpdate( cvt(ffi::EVP_CipherUpdate(
self.ctx, self.ctx,
@ -430,7 +430,7 @@ impl Crypter {
/// `update`. /// `update`.
pub fn aad_update(&mut self, input: &[u8]) -> Result<(), ErrorStack> { pub fn aad_update(&mut self, input: &[u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(input.len() <= c_int::max_value() as usize); assert!(input.len() <= c_int::MAX as usize);
let mut len = 0; let mut len = 0;
cvt(ffi::EVP_CipherUpdate( cvt(ffi::EVP_CipherUpdate(
self.ctx, self.ctx,
@ -456,7 +456,7 @@ impl Crypter {
/// Panics for block ciphers if `output.len() < input.len() + block_size`, /// Panics for block ciphers if `output.len() < input.len() + block_size`,
/// where `block_size` is the block size of the cipher (see `Cipher::block_size`). /// where `block_size` is the block size of the cipher (see `Cipher::block_size`).
/// ///
/// Panics if `output.len() > c_int::max_value()`. /// Panics if `output.len() > c_int::MAX`.
pub fn update(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize, ErrorStack> { pub fn update(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize, ErrorStack> {
unsafe { unsafe {
let block_size = if self.block_size > 1 { let block_size = if self.block_size > 1 {
@ -465,7 +465,7 @@ impl Crypter {
0 0
}; };
assert!(output.len() >= input.len() + block_size); assert!(output.len() >= input.len() + block_size);
assert!(output.len() <= c_int::max_value() as usize); assert!(output.len() <= c_int::MAX as usize);
let mut outl = output.len() as c_int; let mut outl = output.len() as c_int;
let inl = input.len() as c_int; let inl = input.len() as c_int;
@ -497,7 +497,7 @@ impl Crypter {
if self.block_size > 1 { if self.block_size > 1 {
assert!(output.len() >= self.block_size); assert!(output.len() >= self.block_size);
} }
let mut outl = cmp::min(output.len(), c_int::max_value() as usize) as c_int; let mut outl = cmp::min(output.len(), c_int::MAX as usize) as c_int;
cvt(ffi::EVP_CipherFinal_ex( cvt(ffi::EVP_CipherFinal_ex(
self.ctx, self.ctx,
@ -519,7 +519,7 @@ impl Crypter {
/// bytes, for example. /// bytes, for example.
pub fn get_tag(&self, tag: &mut [u8]) -> Result<(), ErrorStack> { pub fn get_tag(&self, tag: &mut [u8]) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(tag.len() <= c_int::max_value() as usize); assert!(tag.len() <= c_int::MAX as usize);
cvt(ffi::EVP_CIPHER_CTX_ctrl( cvt(ffi::EVP_CIPHER_CTX_ctrl(
self.ctx, self.ctx,
ffi::EVP_CTRL_GCM_GET_TAG, ffi::EVP_CTRL_GCM_GET_TAG,

View File

@ -898,7 +898,7 @@ impl X509NameBuilder {
pub fn append_entry_by_text(&mut self, field: &str, value: &str) -> Result<(), ErrorStack> { pub fn append_entry_by_text(&mut self, field: &str, value: &str) -> Result<(), ErrorStack> {
unsafe { unsafe {
let field = CString::new(field).unwrap(); let field = CString::new(field).unwrap();
assert!(value.len() <= ValueLen::max_value() as usize); assert!(value.len() <= ValueLen::MAX as usize);
cvt(ffi::X509_NAME_add_entry_by_txt( cvt(ffi::X509_NAME_add_entry_by_txt(
self.0.as_ptr(), self.0.as_ptr(),
field.as_ptr() as *mut _, field.as_ptr() as *mut _,
@ -925,7 +925,7 @@ impl X509NameBuilder {
) -> Result<(), ErrorStack> { ) -> Result<(), ErrorStack> {
unsafe { unsafe {
let field = CString::new(field).unwrap(); let field = CString::new(field).unwrap();
assert!(value.len() <= ValueLen::max_value() as usize); assert!(value.len() <= ValueLen::MAX as usize);
cvt(ffi::X509_NAME_add_entry_by_txt( cvt(ffi::X509_NAME_add_entry_by_txt(
self.0.as_ptr(), self.0.as_ptr(),
field.as_ptr() as *mut _, field.as_ptr() as *mut _,
@ -946,7 +946,7 @@ impl X509NameBuilder {
/// [`X509_NAME_add_entry_by_NID`]: https://www.openssl.org/docs/man1.1.0/crypto/X509_NAME_add_entry_by_NID.html /// [`X509_NAME_add_entry_by_NID`]: https://www.openssl.org/docs/man1.1.0/crypto/X509_NAME_add_entry_by_NID.html
pub fn append_entry_by_nid(&mut self, field: Nid, value: &str) -> Result<(), ErrorStack> { pub fn append_entry_by_nid(&mut self, field: Nid, value: &str) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(value.len() <= ValueLen::max_value() as usize); assert!(value.len() <= ValueLen::MAX as usize);
cvt(ffi::X509_NAME_add_entry_by_NID( cvt(ffi::X509_NAME_add_entry_by_NID(
self.0.as_ptr(), self.0.as_ptr(),
field.as_raw(), field.as_raw(),
@ -972,7 +972,7 @@ impl X509NameBuilder {
ty: Asn1Type, ty: Asn1Type,
) -> Result<(), ErrorStack> { ) -> Result<(), ErrorStack> {
unsafe { unsafe {
assert!(value.len() <= ValueLen::max_value() as usize); assert!(value.len() <= ValueLen::MAX as usize);
cvt(ffi::X509_NAME_add_entry_by_NID( cvt(ffi::X509_NAME_add_entry_by_NID(
self.0.as_ptr(), self.0.as_ptr(),
field.as_raw(), field.as_raw(),