Skip to content

Commit

Permalink
Release openssl v0.10.36
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Aug 17, 2021
1 parent 040ec64 commit d95befd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 33 deletions.
3 changes: 2 additions & 1 deletion openssl-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@
* Added `X509_verify` and `X509_REQ_verify`.
* Added `EVP_MD_type` and `EVP_GROUP_get_curve_name`.

[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.65...master
[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.66...master
[v0.9.66]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.65...openssl-sys-v0.9.66
[v0.9.65]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.64...openssl-sys-v0.9.65
[v0.9.64]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.63...openssl-sys-v0.9.64
[v0.9.63]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.62...openssl-sys-v0.9.63
Expand Down
12 changes: 11 additions & 1 deletion openssl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

## [v0.10.36] - 2021-08-17

### Added

* Added `Asn1Object::as_slice`.
* Added `PKeyRef::{raw_public_key, raw_private_key, private_key_to_pkcs8_passphrase}` and
`PKey::{private_key_from_raw_bytes, public_key_from_raw_bytes}`.
* Added `Cipher::{seed_cbc, seed_cfb128, seed_ecb, seed_ofb}`.

## [v0.10.35] - 2021-06-18

### Fixed
Expand Down Expand Up @@ -547,7 +556,8 @@

Look at the [release tags] for information about older releases.

[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.35...master
[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.36...master
[v0.10.36]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.35...openssl-v0.10.36
[v0.10.35]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.34...openssl-v0.10.35
[v0.10.34]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.33...openssl-v0.10.34
[v0.10.33]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.32...openssl-v0.10.33
Expand Down
4 changes: 2 additions & 2 deletions openssl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openssl"
version = "0.10.35"
version = "0.10.36"
authors = ["Steven Fackler <[email protected]>"]
license = "Apache-2.0"
description = "OpenSSL bindings"
Expand All @@ -26,7 +26,7 @@ foreign-types = "0.3.1"
libc = "0.2"
once_cell = "1.5.2"

ffi = { package = "openssl-sys", version = "0.9.64", path = "../openssl-sys" }
ffi = { package = "openssl-sys", version = "0.9.66", path = "../openssl-sys" }

[dev-dependencies]
tempdir = "0.3"
Expand Down
58 changes: 29 additions & 29 deletions openssl/src/pkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,35 @@ where
Ok(buf)
}
}

/// Serializes a private key into a DER-formatted PKCS#8, using the supplied password to
/// encrypt the key.
///
/// # Panics
///
/// Panics if `passphrase` contains an embedded null.
pub fn private_key_to_pkcs8_passphrase(
&self,
cipher: Cipher,
passphrase: &[u8],
) -> Result<Vec<u8>, ErrorStack> {
unsafe {
let bio = MemBio::new()?;
let len = passphrase.len();
let passphrase = CString::new(passphrase).unwrap();
cvt(ffi::i2d_PKCS8PrivateKey_bio(
bio.as_ptr(),
self.as_ptr(),
cipher.as_ptr(),
passphrase.as_ptr() as *const _ as *mut _,
len as ::libc::c_int,
None,
ptr::null_mut(),
))?;

Ok(bio.get_buf().to_owned())
}
}
}

impl<T> fmt::Debug for PKey<T> {
Expand Down Expand Up @@ -683,35 +712,6 @@ impl PKey<Private> {
}
}

/// Serializes a private key into a DER-formatted PKCS#8, using the supplied password to
/// encrypt the key.
///
/// # Panics
///
/// Panics if `passphrase` contains an embedded null.
pub fn private_key_to_pkcs8_passphrase(
&self,
cipher: Cipher,
passphrase: &[u8],
) -> Result<Vec<u8>, ErrorStack> {
unsafe {
let bio = MemBio::new()?;
let len = passphrase.len();
let passphrase = CString::new(passphrase).unwrap();
cvt(ffi::i2d_PKCS8PrivateKey_bio(
bio.as_ptr(),
self.as_ptr(),
cipher.as_ptr(),
passphrase.as_ptr() as *const _ as *mut _,
len as ::libc::c_int,
None,
ptr::null_mut(),
))?;

Ok(bio.get_buf().to_owned())
}
}

/// Creates a private key from its raw byte representation
///
/// Algorithm types that support raw private keys are HMAC, X25519, ED25519, X448 or ED448
Expand Down

0 comments on commit d95befd

Please sign in to comment.