-
-
Notifications
You must be signed in to change notification settings - Fork 774
add HPKE bindings #2337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tofay
wants to merge
1
commit into
sfackler:master
Choose a base branch
from
tofay:hpke
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add HPKE bindings #2337
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use super::super::*; | ||
use libc::*; | ||
|
||
extern "C" { | ||
pub fn OSSL_HPKE_CTX_new( | ||
mode: c_int, | ||
suite: OSSL_HPKE_SUITE, | ||
role: c_int, | ||
libctx: *mut OSSL_LIB_CTX, | ||
propq: *const c_char, | ||
) -> *mut OSSL_HPKE_CTX; | ||
pub fn OSSL_HPKE_CTX_free(ctx: *mut OSSL_HPKE_CTX); | ||
pub fn OSSL_HPKE_encap( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
enc: *mut u8, | ||
enclen: *mut usize, | ||
pub_: *const u8, | ||
publen: usize, | ||
info: *const u8, | ||
infolen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_seal( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
ct: *mut u8, | ||
ctlen: *mut usize, | ||
aad: *const u8, | ||
aadlen: usize, | ||
pt: *const u8, | ||
ptlen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_keygen( | ||
suite: OSSL_HPKE_SUITE, | ||
pub_: *mut u8, | ||
publen: *mut usize, | ||
priv_: *mut *mut EVP_PKEY, | ||
ikm: *const u8, | ||
ikmlen: usize, | ||
libctx: *mut OSSL_LIB_CTX, | ||
propq: *const c_char, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_decap( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
enc: *const u8, | ||
enclen: usize, | ||
recippriv: *mut EVP_PKEY, | ||
info: *const u8, | ||
infolen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_open( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
pt: *mut u8, | ||
ptlen: *mut usize, | ||
aad: *const u8, | ||
aadlen: usize, | ||
ct: *const u8, | ||
ctlen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_export( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
secret: *mut u8, | ||
secretlen: usize, | ||
label: *const u8, | ||
labellen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_CTX_set1_authpriv(ctx: *mut OSSL_HPKE_CTX, priv_: *mut EVP_PKEY) -> c_int; | ||
pub fn OSSL_HPKE_CTX_set1_authpub( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
pub_: *const u8, | ||
publen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_CTX_set1_psk( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
pskid: *const c_char, | ||
psk: *const u8, | ||
psklen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_CTX_set1_ikme( | ||
ctx: *mut OSSL_HPKE_CTX, | ||
ikme: *const u8, | ||
ikmelen: usize, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_CTX_set_seq(ctx: *mut OSSL_HPKE_CTX, seq: u64) -> c_int; | ||
pub fn OSSL_HPKE_CTX_get_seq(ctx: *mut OSSL_HPKE_CTX, seq: *mut u64) -> c_int; | ||
pub fn OSSL_HPKE_suite_check(suite: OSSL_HPKE_SUITE) -> c_int; | ||
pub fn OSSL_HPKE_get_grease_value( | ||
suite_in: *const OSSL_HPKE_SUITE, | ||
suite: *mut OSSL_HPKE_SUITE, | ||
enc: *mut u8, | ||
enclen: *mut usize, | ||
ct: *mut u8, | ||
ctlen: usize, | ||
libctx: *mut OSSL_LIB_CTX, | ||
propq: *const c_char, | ||
) -> c_int; | ||
pub fn OSSL_HPKE_str2suite(str_: *const c_char, suite: *mut OSSL_HPKE_SUITE) -> c_int; | ||
pub fn OSSL_HPKE_get_ciphertext_size(suite: OSSL_HPKE_SUITE, clearlen: usize) -> usize; | ||
pub fn OSSL_HPKE_get_public_encap_size(suite: OSSL_HPKE_SUITE) -> usize; | ||
pub fn OSSL_HPKE_get_recommended_ikmelen(suite: OSSL_HPKE_SUITE) -> usize; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#[cfg(ossl320)] | ||
use crate::OSSL_HPKE_SUITE; | ||
use libc::c_int; | ||
|
||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_MODE_BASE: c_int = 0x00; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_MODE_PSK: c_int = 0x01; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_MODE_AUTH: c_int = 0x02; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_MODE_PSKAUTH: c_int = 0x03; | ||
|
||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_ROLE_SENDER: c_int = 0x00; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_ROLE_RECEIVER: c_int = 0x01; | ||
|
||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KEM_ID_P256: u16 = 0x10; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KEM_ID_P384: u16 = 0x11; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KEM_ID_P521: u16 = 0x12; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KEM_ID_X25519: u16 = 0x20; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KEM_ID_X448: u16 = 0x21; | ||
|
||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KDF_ID_HKDF_SHA256: u16 = 0x01; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KDF_ID_HKDF_SHA384: u16 = 0x02; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_KDF_ID_HKDF_SHA512: u16 = 0x03; | ||
|
||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_AEAD_ID_AES_GCM_128: u16 = 0x01; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_AEAD_ID_AES_GCM_256: u16 = 0x02; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_AEAD_ID_CHACHA_POLY1305: u16 = 0x03; | ||
#[cfg(ossl320)] | ||
pub const OSSL_HPKE_AEAD_ID_EXPORTONLY: u16 = 0xFFFF; | ||
|
||
#[cfg(all(ossl320, not(osslconf = "OPENSSL_NO_ECX")))] | ||
pub const OSSL_HPKE_SUITE_DEFAULT: OSSL_HPKE_SUITE = OSSL_HPKE_SUITE { | ||
kem_id: OSSL_HPKE_KEM_ID_X25519, | ||
kdf_id: OSSL_HPKE_KDF_ID_HKDF_SHA256, | ||
aead_id: OSSL_HPKE_AEAD_ID_AES_GCM_128, | ||
}; | ||
|
||
#[cfg(all(ossl320, osslconf = "OPENSSL_NO_ECX"))] | ||
pub const OSSL_HPKE_SUITE_DEFAULT: OSSL_HPKE_SUITE = OSSL_HPKE_SUITE { | ||
kem_id: OSSL_HPKE_KEM_ID_P256, | ||
kdf_id: OSSL_HPKE_KDF_ID_HKDF_SHA256, | ||
aead_id: OSSL_HPKE_AEAD_ID_AES_GCM_128, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.