Skip to content

Commit 073521c

Browse files
committed
Merge #555: Backport and bump version to 0.22.2
12e67f1 Bump version to 0.22.2 (Tobin C. Harding) 7604f32 Add saftey docs for PreallocatedContext trait (Tobin C. Harding) 357e800 context: introduce unsafe `PreallocatedContext` trait (Andrew Poelstra) Pull request description: Backport #548 and bump version ready for release. ACKs for top commit: Kixunil: ACK 12e67f1 Tree-SHA512: 6e2e700ecede75b00a6629e314f814946d4a929e5a5b1540b663cf5b338dae4fa7eda293dd6877888976892c834eb63a53ce29938d451e6062ed3d6db3ad6429
2 parents de65fb2 + 12e67f1 commit 073521c

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.22.2 - 2022-12-05
2+
3+
* Backport [fix soundness issue with `preallocated_gen_new`](https://github.com/rust-bitcoin/rust-secp256k1/pull/548)
4+
15
# 0.22.1 - 2022-03-10
26

37
* [Reintroduce](https://github.com/rust-bitcoin/rust-secp256k1/pull/417) accidentally removed possibility to create `SharedSecret` from byte serialization

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "secp256k1"
3-
version = "0.22.1"
3+
version = "0.22.2"
44
authors = [ "Dawid Ciężarkiewicz <dpc@ucore.info>",
55
"Andrew Poelstra <apoelstra@wpsoftware.net>" ]
66
license = "CC0-1.0"

src/context.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,22 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> {
299299
}
300300
}
301301

302-
impl<'buf, C: Context + 'buf> Secp256k1<C> {
303-
/// Lets you create a context with preallocated buffer in a generic manner(sign/verify/all)
302+
/// Trait marking that a particular context object internally points to
303+
/// memory that must outlive `'a`
304+
///
305+
/// # Safety
306+
///
307+
/// This trait is used internally to gate which context markers can safely
308+
/// be used with the `preallocated_gen_new` function. Do not implement it
309+
/// on your own structures.
310+
pub unsafe trait PreallocatedContext<'a> {}
311+
312+
unsafe impl<'buf> PreallocatedContext<'buf> for AllPreallocated<'buf> {}
313+
unsafe impl<'buf> PreallocatedContext<'buf> for SignOnlyPreallocated<'buf> {}
314+
unsafe impl<'buf> PreallocatedContext<'buf> for VerifyOnlyPreallocated<'buf> {}
315+
316+
impl<'buf, C: Context + PreallocatedContext<'buf>> Secp256k1<C> {
317+
/// Lets you create a context with a preallocated buffer in a generic manner (sign/verify/all).
304318
pub fn preallocated_gen_new(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<C>, Error> {
305319
#[cfg(target_arch = "wasm32")]
306320
ffi::types::sanity_checks_for_wasm();

0 commit comments

Comments
 (0)