Skip to content

Commit 0a34876

Browse files
authored
Merge pull request #1998 from trail-of-forks/poly1305-bindings
Expose Poly1305 bindings on libressl and boringssl
2 parents e1fd4da + 55ee0da commit 0a34876

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

openssl-sys/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
* Expose `poly1305_state`, `CRYPTO_poly1305_init`, `CRYPTO_poly1305_update`, and `CRYPTO_poly1305_finish` on BoringSSL and LibreSSL.
8+
59
## [v0.9.90] - 2023-06-20
610

711
### Fixed

openssl-sys/build/run_bindgen.rs

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const INCLUDES: &str = "
5555
#if OPENSSL_VERSION_NUMBER >= 0x30000000
5656
#include <openssl/provider.h>
5757
#endif
58+
59+
#if defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_IS_BORINGSSL)
60+
#include <openssl/poly1305.h>
61+
#endif
5862
";
5963

6064
#[cfg(feature = "bindgen")]

openssl-sys/src/handwritten/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub use self::ocsp::*;
1818
pub use self::pem::*;
1919
pub use self::pkcs12::*;
2020
pub use self::pkcs7::*;
21+
#[cfg(libressl)]
22+
pub use self::poly1305::*;
2123
pub use self::provider::*;
2224
pub use self::rand::*;
2325
pub use self::rsa::*;
@@ -52,6 +54,8 @@ mod ocsp;
5254
mod pem;
5355
mod pkcs12;
5456
mod pkcs7;
57+
#[cfg(libressl)]
58+
mod poly1305;
5559
mod provider;
5660
mod rand;
5761
mod rsa;
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use super::super::*;
2+
use libc::*;
3+
4+
cfg_if! {
5+
if #[cfg(libressl)] {
6+
#[repr(C)]
7+
#[derive(Debug, Copy, Clone)]
8+
pub struct poly1305_context {
9+
pub aligner: usize,
10+
pub opaque: [::libc::c_uchar; 136usize],
11+
}
12+
pub type poly1305_state = poly1305_context;
13+
extern "C" {
14+
pub fn CRYPTO_poly1305_init(ctx: *mut poly1305_context, key: *const ::libc::c_uchar);
15+
pub fn CRYPTO_poly1305_update(
16+
ctx: *mut poly1305_context,
17+
in_: *const ::libc::c_uchar,
18+
len: usize,
19+
);
20+
pub fn CRYPTO_poly1305_finish(ctx: *mut poly1305_context, mac: *mut ::libc::c_uchar);
21+
}
22+
}
23+
}

systest/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ fn main() {
6969
.header("openssl/evp.h")
7070
.header("openssl/x509_vfy.h");
7171

72+
if libressl_version.is_some() {
73+
cfg.header("openssl/poly1305.h");
74+
}
75+
7276
if let Some(version) = openssl_version {
7377
cfg.header("openssl/cms.h");
7478
if version >= 0x10100000 {

0 commit comments

Comments
 (0)