Skip to content

Commit 28be7ed

Browse files
authored
Merge pull request #2282 from rushilmehra/update-docs
Update some docs to use the corresponds macro
2 parents 7000b5d + da75d41 commit 28be7ed

File tree

7 files changed

+50
-208
lines changed

7 files changed

+50
-208
lines changed

openssl/src/cipher_ctx.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,6 @@ impl CipherCtxRef {
328328
///
329329
/// Panics if the context has not been initialized with a cipher or if the buffer is smaller than the cipher's key
330330
/// length.
331-
///
332-
/// This corresponds to [`EVP_CIPHER_CTX_rand_key`].
333-
///
334-
/// [`EVP_CIPHER_CTX_rand_key`]: https://www.openssl.org/docs/manmaster/man3/EVP_CIPHER_CTX_rand_key.html
335331
#[corresponds(EVP_CIPHER_CTX_rand_key)]
336332
#[cfg(not(boringssl))]
337333
pub fn rand_key(&self, buf: &mut [u8]) -> Result<(), ErrorStack> {

openssl/src/hash.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use std::ptr;
4141
use crate::error::ErrorStack;
4242
use crate::nid::Nid;
4343
use crate::{cvt, cvt_p};
44+
use openssl_macros::corresponds;
4445

4546
cfg_if! {
4647
if #[cfg(any(ossl110, boringssl, libressl382))] {
@@ -65,10 +66,7 @@ impl MessageDigest {
6566
}
6667

6768
/// Returns the `MessageDigest` corresponding to an `Nid`.
68-
///
69-
/// This corresponds to [`EVP_get_digestbynid`].
70-
///
71-
/// [`EVP_get_digestbynid`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestInit.html
69+
#[corresponds(EVP_get_digestbynid)]
7270
pub fn from_nid(type_: Nid) -> Option<MessageDigest> {
7371
ffi::init();
7472
unsafe {
@@ -82,10 +80,7 @@ impl MessageDigest {
8280
}
8381

8482
/// Returns the `MessageDigest` corresponding to an algorithm name.
85-
///
86-
/// This corresponds to [`EVP_get_digestbyname`].
87-
///
88-
/// [`EVP_get_digestbyname`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestInit.html
83+
#[corresponds(EVP_get_digestbyname)]
8984
pub fn from_name(name: &str) -> Option<MessageDigest> {
9085
ffi::init();
9186
let name = CString::new(name).ok()?;

openssl/src/nid.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ impl Nid {
7979
}
8080

8181
/// Returns the `Nid`s of the digest and public key algorithms associated with a signature ID.
82-
///
83-
/// This corresponds to `OBJ_find_sigid_algs`.
8482
#[corresponds(OBJ_find_sigid_algs)]
8583
#[allow(clippy::trivially_copy_pass_by_ref)]
8684
pub fn signature_algorithms(&self) -> Option<SignatureAlgorithms> {

openssl/src/sign.rs

Lines changed: 20 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ use crate::hash::MessageDigest;
7979
use crate::pkey::{HasPrivate, HasPublic, PKeyRef};
8080
use crate::rsa::Padding;
8181
use crate::{cvt, cvt_p};
82+
use openssl_macros::corresponds;
8283

8384
cfg_if! {
8485
if #[cfg(any(ossl110, libressl382))] {
@@ -135,10 +136,7 @@ impl Signer<'_> {
135136
///
136137
/// This cannot be used with Ed25519 or Ed448 keys. Please refer to
137138
/// `new_without_digest`.
138-
///
139-
/// OpenSSL documentation at [`EVP_DigestSignInit`].
140-
///
141-
/// [`EVP_DigestSignInit`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestSignInit.html
139+
#[corresponds(EVP_DigestSignInit)]
142140
pub fn new<'a, T>(type_: MessageDigest, pkey: &PKeyRef<T>) -> Result<Signer<'a>, ErrorStack>
143141
where
144142
T: HasPrivate,
@@ -150,10 +148,7 @@ impl Signer<'_> {
150148
///
151149
/// This is the only way to create a `Verifier` for Ed25519 or Ed448 keys.
152150
/// It can also be used to create a CMAC.
153-
///
154-
/// OpenSSL documentation at [`EVP_DigestSignInit`].
155-
///
156-
/// [`EVP_DigestSignInit`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestSignInit.html
151+
#[corresponds(EVP_DigestSignInit)]
157152
pub fn new_without_digest<'a, T>(pkey: &PKeyRef<T>) -> Result<Signer<'a>, ErrorStack>
158153
where
159154
T: HasPrivate,
@@ -198,8 +193,7 @@ impl Signer<'_> {
198193
/// Returns the RSA padding mode in use.
199194
///
200195
/// This is only useful for RSA keys.
201-
///
202-
/// This corresponds to `EVP_PKEY_CTX_get_rsa_padding`.
196+
#[corresponds(EVP_PKEY_CTX_get_rsa_padding)]
203197
pub fn rsa_padding(&self) -> Result<Padding, ErrorStack> {
204198
unsafe {
205199
let mut pad = 0;
@@ -211,10 +205,7 @@ impl Signer<'_> {
211205
/// Sets the RSA padding mode.
212206
///
213207
/// This is only useful for RSA keys.
214-
///
215-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_padding`].
216-
///
217-
/// [`EVP_PKEY_CTX_set_rsa_padding`]: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_set_rsa_padding.html
208+
#[corresponds(EVP_PKEY_CTX_set_rsa_padding)]
218209
pub fn set_rsa_padding(&mut self, padding: Padding) -> Result<(), ErrorStack> {
219210
unsafe {
220211
cvt(ffi::EVP_PKEY_CTX_set_rsa_padding(
@@ -228,10 +219,7 @@ impl Signer<'_> {
228219
/// Sets the RSA PSS salt length.
229220
///
230221
/// This is only useful for RSA keys.
231-
///
232-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_pss_saltlen`].
233-
///
234-
/// [`EVP_PKEY_CTX_set_rsa_pss_saltlen`]: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_set_rsa_pss_saltlen.html
222+
#[corresponds(EVP_PKEY_CTX_set_rsa_pss_saltlen)]
235223
pub fn set_rsa_pss_saltlen(&mut self, len: RsaPssSaltlen) -> Result<(), ErrorStack> {
236224
unsafe {
237225
cvt(ffi::EVP_PKEY_CTX_set_rsa_pss_saltlen(
@@ -245,10 +233,7 @@ impl Signer<'_> {
245233
/// Sets the RSA MGF1 algorithm.
246234
///
247235
/// This is only useful for RSA keys.
248-
///
249-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_mgf1_md`].
250-
///
251-
/// [`EVP_PKEY_CTX_set_rsa_mgf1_md`]: https://www.openssl.org/docs/manmaster/man7/RSA-PSS.html
236+
#[corresponds(EVP_PKEY_CTX_set_rsa_mgf1_md)]
252237
pub fn set_rsa_mgf1_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack> {
253238
unsafe {
254239
cvt(ffi::EVP_PKEY_CTX_set_rsa_mgf1_md(
@@ -263,10 +248,7 @@ impl Signer<'_> {
263248
///
264249
/// Please note that PureEdDSA (Ed25519 and Ed448 keys) do not support streaming.
265250
/// Use `sign_oneshot` instead.
266-
///
267-
/// OpenSSL documentation at [`EVP_DigestUpdate`].
268-
///
269-
/// [`EVP_DigestUpdate`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestInit.html
251+
#[corresponds(EVP_DigestUpdate)]
270252
pub fn update(&mut self, buf: &[u8]) -> Result<(), ErrorStack> {
271253
unsafe {
272254
cvt(ffi::EVP_DigestUpdate(
@@ -282,10 +264,7 @@ impl Signer<'_> {
282264
///
283265
/// The actual signature may be shorter than this value. Check the return value of
284266
/// `sign` to get the exact length.
285-
///
286-
/// OpenSSL documentation at [`EVP_DigestSignFinal`].
287-
///
288-
/// [`EVP_DigestSignFinal`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestSignFinal.html
267+
#[corresponds(EVP_DigestSignFinal)]
289268
pub fn len(&self) -> Result<usize, ErrorStack> {
290269
self.len_intern()
291270
}
@@ -322,10 +301,7 @@ impl Signer<'_> {
322301
///
323302
/// This method will fail if the buffer is not large enough for the signature. Use the `len`
324303
/// method to get an upper bound on the required size.
325-
///
326-
/// OpenSSL documentation at [`EVP_DigestSignFinal`].
327-
///
328-
/// [`EVP_DigestSignFinal`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestSignFinal.html
304+
#[corresponds(EVP_DigestSignFinal)]
329305
pub fn sign(&self, buf: &mut [u8]) -> Result<usize, ErrorStack> {
330306
unsafe {
331307
let mut len = buf.len();
@@ -356,10 +332,7 @@ impl Signer<'_> {
356332
///
357333
/// This method will fail if the buffer is not large enough for the signature. Use the `len`
358334
/// method to get an upper bound on the required size.
359-
///
360-
/// OpenSSL documentation at [`EVP_DigestSign`].
361-
///
362-
/// [`EVP_DigestSign`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DigestSign.html
335+
#[corresponds(EVP_DigestSign)]
363336
#[cfg(any(ossl111, boringssl, libressl370))]
364337
pub fn sign_oneshot(
365338
&mut self,
@@ -429,10 +402,7 @@ impl<'a> Verifier<'a> {
429402
///
430403
/// This cannot be used with Ed25519 or Ed448 keys. Please refer to
431404
/// [`Verifier::new_without_digest`].
432-
///
433-
/// OpenSSL documentation at [`EVP_DigestVerifyInit`].
434-
///
435-
/// [`EVP_DigestVerifyInit`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestVerifyInit.html
405+
#[corresponds(EVP_DigestVerifyInit)]
436406
pub fn new<T>(type_: MessageDigest, pkey: &'a PKeyRef<T>) -> Result<Verifier<'a>, ErrorStack>
437407
where
438408
T: HasPublic,
@@ -443,10 +413,7 @@ impl<'a> Verifier<'a> {
443413
/// Creates a new `Verifier` without a digest.
444414
///
445415
/// This is the only way to create a `Verifier` for Ed25519 or Ed448 keys.
446-
///
447-
/// OpenSSL documentation at [`EVP_DigestVerifyInit`].
448-
///
449-
/// [`EVP_DigestVerifyInit`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestVerifyInit.html
416+
#[corresponds(EVP_DigestVerifyInit)]
450417
pub fn new_without_digest<T>(pkey: &'a PKeyRef<T>) -> Result<Verifier<'a>, ErrorStack>
451418
where
452419
T: HasPublic,
@@ -491,8 +458,7 @@ impl<'a> Verifier<'a> {
491458
/// Returns the RSA padding mode in use.
492459
///
493460
/// This is only useful for RSA keys.
494-
///
495-
/// This corresponds to `EVP_PKEY_CTX_get_rsa_padding`.
461+
#[corresponds(EVP_PKEY_CTX_get_rsa_padding)]
496462
pub fn rsa_padding(&self) -> Result<Padding, ErrorStack> {
497463
unsafe {
498464
let mut pad = 0;
@@ -504,10 +470,7 @@ impl<'a> Verifier<'a> {
504470
/// Sets the RSA padding mode.
505471
///
506472
/// This is only useful for RSA keys.
507-
///
508-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_padding`].
509-
///
510-
/// [`EVP_PKEY_CTX_set_rsa_padding`]: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_set_rsa_padding.html
473+
#[corresponds(EVP_PKEY_CTX_set_rsa_padding)]
511474
pub fn set_rsa_padding(&mut self, padding: Padding) -> Result<(), ErrorStack> {
512475
unsafe {
513476
cvt(ffi::EVP_PKEY_CTX_set_rsa_padding(
@@ -521,10 +484,7 @@ impl<'a> Verifier<'a> {
521484
/// Sets the RSA PSS salt length.
522485
///
523486
/// This is only useful for RSA keys.
524-
///
525-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_pss_saltlen`].
526-
///
527-
/// [`EVP_PKEY_CTX_set_rsa_pss_saltlen`]: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_set_rsa_pss_saltlen.html
487+
#[corresponds(EVP_PKEY_CTX_set_rsa_pss_saltlen)]
528488
pub fn set_rsa_pss_saltlen(&mut self, len: RsaPssSaltlen) -> Result<(), ErrorStack> {
529489
unsafe {
530490
cvt(ffi::EVP_PKEY_CTX_set_rsa_pss_saltlen(
@@ -538,10 +498,7 @@ impl<'a> Verifier<'a> {
538498
/// Sets the RSA MGF1 algorithm.
539499
///
540500
/// This is only useful for RSA keys.
541-
///
542-
/// This corresponds to [`EVP_PKEY_CTX_set_rsa_mgf1_md`].
543-
///
544-
/// [`EVP_PKEY_CTX_set_rsa_mgf1_md`]: https://www.openssl.org/docs/manmaster/man7/RSA-PSS.html
501+
#[corresponds(EVP_PKEY_CTX_set_rsa_mgf1_md)]
545502
pub fn set_rsa_mgf1_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack> {
546503
unsafe {
547504
cvt(ffi::EVP_PKEY_CTX_set_rsa_mgf1_md(
@@ -556,10 +513,7 @@ impl<'a> Verifier<'a> {
556513
///
557514
/// Please note that PureEdDSA (Ed25519 and Ed448 keys) do not support streaming.
558515
/// Use [`Verifier::verify_oneshot`] instead.
559-
///
560-
/// OpenSSL documentation at [`EVP_DigestUpdate`].
561-
///
562-
/// [`EVP_DigestUpdate`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestInit.html
516+
#[corresponds(EVP_DigestUpdate)]
563517
pub fn update(&mut self, buf: &[u8]) -> Result<(), ErrorStack> {
564518
unsafe {
565519
cvt(ffi::EVP_DigestUpdate(
@@ -572,10 +526,7 @@ impl<'a> Verifier<'a> {
572526
}
573527

574528
/// Determines if the data fed into the `Verifier` matches the provided signature.
575-
///
576-
/// OpenSSL documentation at [`EVP_DigestVerifyFinal`].
577-
///
578-
/// [`EVP_DigestVerifyFinal`]: https://www.openssl.org/docs/manmaster/man3/EVP_DigestVerifyFinal.html
529+
#[corresponds(EVP_DigestVerifyFinal)]
579530
pub fn verify(&self, signature: &[u8]) -> Result<bool, ErrorStack> {
580531
unsafe {
581532
let r =
@@ -592,10 +543,7 @@ impl<'a> Verifier<'a> {
592543
}
593544

594545
/// Determines if the data given in `buf` matches the provided signature.
595-
///
596-
/// OpenSSL documentation at [`EVP_DigestVerify`].
597-
///
598-
/// [`EVP_DigestVerify`]: https://www.openssl.org/docs/man1.1.1/man3/EVP_DigestVerify.html
546+
#[corresponds(EVP_DigestVerify)]
599547
#[cfg(any(ossl111, boringssl, libressl370))]
600548
pub fn verify_oneshot(&mut self, signature: &[u8], buf: &[u8]) -> Result<bool, ErrorStack> {
601549
unsafe {

0 commit comments

Comments
 (0)