Commit da7f26d5 authored by bdbai's avatar bdbai
Browse files

fix max_values()

parent 864662b1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ impl AesKey {
    #[corresponds(AES_set_encrypt_key)]
    pub fn new_encrypt(key: &[u8]) -> Result<AesKey, KeyError> {
        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 r = ffi::AES_set_encrypt_key(
@@ -119,7 +119,7 @@ impl AesKey {
    #[corresponds(AES_set_decrypt_key)]
    pub fn new_decrypt(key: &[u8]) -> Result<AesKey, KeyError> {
        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 r = ffi::AES_set_decrypt_key(
+2 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ use openssl_macros::corresponds;
/// Panics if the input length or computed output length overflow a signed C integer.
#[corresponds(EVP_EncodeBlock)]
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() as LenType;

    let len = encoded_len(src_len).unwrap();
@@ -42,7 +42,7 @@ pub fn decode_block(src: &str) -> Result<Vec<u8>, ErrorStack> {
        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() as LenType;

    let len = decoded_len(src_len).unwrap();
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ impl<'a> MemBioSlice<'a> {
    pub fn new(buf: &'a [u8]) -> Result<MemBioSlice<'a>, ErrorStack> {
        ffi::init();

        assert!(buf.len() <= c_int::max_value() as usize);
        assert!(buf.len() <= c_int::MAX as usize);
        let bio = unsafe {
            cvt_p(BIO_new_mem_buf(
                buf.as_ptr() as *const _,
+4 −4
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ impl BigNumRef {
    pub fn div_word(&mut self, w: u32) -> Result<u64, ErrorStack> {
        unsafe {
            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())
            } else {
                Ok(r.into())
@@ -201,7 +201,7 @@ impl BigNumRef {
    pub fn mod_word(&self, w: u32) -> Result<u64, ErrorStack> {
        unsafe {
            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())
            } else {
                Ok(r.into())
@@ -1108,7 +1108,7 @@ impl BigNum {
    pub fn from_slice(n: &[u8]) -> Result<BigNum, ErrorStack> {
        unsafe {
            ffi::init();
            assert!(n.len() <= LenType::max_value() as usize);
            assert!(n.len() <= LenType::MAX as usize);

            cvt_p(ffi::BN_bin2bn(
                n.as_ptr(),
@@ -1136,7 +1136,7 @@ impl BigNum {
    #[corresponds(BN_bin2bn)]
    pub fn copy_from_slice(&mut self, n: &[u8]) -> Result<(), ErrorStack> {
        unsafe {
            assert!(n.len() <= LenType::max_value() as usize);
            assert!(n.len() <= LenType::MAX as usize);

            cvt_p(ffi::BN_bin2bn(n.as_ptr(), n.len() as LenType, self.0))?;
            Ok(())
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ impl EcdsaSig {
        T: HasPrivate,
    {
        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(
                data.as_ptr(),
                data.len() as LenType,
@@ -77,7 +77,7 @@ impl EcdsaSigRef {
        T: HasPublic,
    {
        unsafe {
            assert!(data.len() <= c_int::max_value() as usize);
            assert!(data.len() <= c_int::MAX as usize);
            cvt_n(ffi::ECDSA_do_verify(
                data.as_ptr(),
                data.len() as LenType,
Loading