@@ -79,6 +79,7 @@ use crate::hash::MessageDigest;
79
79
use crate :: pkey:: { HasPrivate , HasPublic , PKeyRef } ;
80
80
use crate :: rsa:: Padding ;
81
81
use crate :: { cvt, cvt_p} ;
82
+ use openssl_macros:: corresponds;
82
83
83
84
cfg_if ! {
84
85
if #[ cfg( any( ossl110, libressl382) ) ] {
@@ -135,10 +136,7 @@ impl Signer<'_> {
135
136
///
136
137
/// This cannot be used with Ed25519 or Ed448 keys. Please refer to
137
138
/// `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 ) ]
142
140
pub fn new < ' a , T > ( type_ : MessageDigest , pkey : & PKeyRef < T > ) -> Result < Signer < ' a > , ErrorStack >
143
141
where
144
142
T : HasPrivate ,
@@ -150,10 +148,7 @@ impl Signer<'_> {
150
148
///
151
149
/// This is the only way to create a `Verifier` for Ed25519 or Ed448 keys.
152
150
/// 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 ) ]
157
152
pub fn new_without_digest < ' a , T > ( pkey : & PKeyRef < T > ) -> Result < Signer < ' a > , ErrorStack >
158
153
where
159
154
T : HasPrivate ,
@@ -198,8 +193,7 @@ impl Signer<'_> {
198
193
/// Returns the RSA padding mode in use.
199
194
///
200
195
/// 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 ) ]
203
197
pub fn rsa_padding ( & self ) -> Result < Padding , ErrorStack > {
204
198
unsafe {
205
199
let mut pad = 0 ;
@@ -211,10 +205,7 @@ impl Signer<'_> {
211
205
/// Sets the RSA padding mode.
212
206
///
213
207
/// 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 ) ]
218
209
pub fn set_rsa_padding ( & mut self , padding : Padding ) -> Result < ( ) , ErrorStack > {
219
210
unsafe {
220
211
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_padding (
@@ -228,10 +219,7 @@ impl Signer<'_> {
228
219
/// Sets the RSA PSS salt length.
229
220
///
230
221
/// 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 ) ]
235
223
pub fn set_rsa_pss_saltlen ( & mut self , len : RsaPssSaltlen ) -> Result < ( ) , ErrorStack > {
236
224
unsafe {
237
225
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_pss_saltlen (
@@ -245,10 +233,7 @@ impl Signer<'_> {
245
233
/// Sets the RSA MGF1 algorithm.
246
234
///
247
235
/// 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 ) ]
252
237
pub fn set_rsa_mgf1_md ( & mut self , md : MessageDigest ) -> Result < ( ) , ErrorStack > {
253
238
unsafe {
254
239
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_mgf1_md (
@@ -263,10 +248,7 @@ impl Signer<'_> {
263
248
///
264
249
/// Please note that PureEdDSA (Ed25519 and Ed448 keys) do not support streaming.
265
250
/// 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 ) ]
270
252
pub fn update ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , ErrorStack > {
271
253
unsafe {
272
254
cvt ( ffi:: EVP_DigestUpdate (
@@ -282,10 +264,7 @@ impl Signer<'_> {
282
264
///
283
265
/// The actual signature may be shorter than this value. Check the return value of
284
266
/// `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 ) ]
289
268
pub fn len ( & self ) -> Result < usize , ErrorStack > {
290
269
self . len_intern ( )
291
270
}
@@ -322,10 +301,7 @@ impl Signer<'_> {
322
301
///
323
302
/// This method will fail if the buffer is not large enough for the signature. Use the `len`
324
303
/// 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 ) ]
329
305
pub fn sign ( & self , buf : & mut [ u8 ] ) -> Result < usize , ErrorStack > {
330
306
unsafe {
331
307
let mut len = buf. len ( ) ;
@@ -356,10 +332,7 @@ impl Signer<'_> {
356
332
///
357
333
/// This method will fail if the buffer is not large enough for the signature. Use the `len`
358
334
/// 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 ) ]
363
336
#[ cfg( any( ossl111, boringssl, libressl370) ) ]
364
337
pub fn sign_oneshot (
365
338
& mut self ,
@@ -429,10 +402,7 @@ impl<'a> Verifier<'a> {
429
402
///
430
403
/// This cannot be used with Ed25519 or Ed448 keys. Please refer to
431
404
/// [`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 ) ]
436
406
pub fn new < T > ( type_ : MessageDigest , pkey : & ' a PKeyRef < T > ) -> Result < Verifier < ' a > , ErrorStack >
437
407
where
438
408
T : HasPublic ,
@@ -443,10 +413,7 @@ impl<'a> Verifier<'a> {
443
413
/// Creates a new `Verifier` without a digest.
444
414
///
445
415
/// 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 ) ]
450
417
pub fn new_without_digest < T > ( pkey : & ' a PKeyRef < T > ) -> Result < Verifier < ' a > , ErrorStack >
451
418
where
452
419
T : HasPublic ,
@@ -491,8 +458,7 @@ impl<'a> Verifier<'a> {
491
458
/// Returns the RSA padding mode in use.
492
459
///
493
460
/// 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 ) ]
496
462
pub fn rsa_padding ( & self ) -> Result < Padding , ErrorStack > {
497
463
unsafe {
498
464
let mut pad = 0 ;
@@ -504,10 +470,7 @@ impl<'a> Verifier<'a> {
504
470
/// Sets the RSA padding mode.
505
471
///
506
472
/// 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 ) ]
511
474
pub fn set_rsa_padding ( & mut self , padding : Padding ) -> Result < ( ) , ErrorStack > {
512
475
unsafe {
513
476
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_padding (
@@ -521,10 +484,7 @@ impl<'a> Verifier<'a> {
521
484
/// Sets the RSA PSS salt length.
522
485
///
523
486
/// 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 ) ]
528
488
pub fn set_rsa_pss_saltlen ( & mut self , len : RsaPssSaltlen ) -> Result < ( ) , ErrorStack > {
529
489
unsafe {
530
490
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_pss_saltlen (
@@ -538,10 +498,7 @@ impl<'a> Verifier<'a> {
538
498
/// Sets the RSA MGF1 algorithm.
539
499
///
540
500
/// 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 ) ]
545
502
pub fn set_rsa_mgf1_md ( & mut self , md : MessageDigest ) -> Result < ( ) , ErrorStack > {
546
503
unsafe {
547
504
cvt ( ffi:: EVP_PKEY_CTX_set_rsa_mgf1_md (
@@ -556,10 +513,7 @@ impl<'a> Verifier<'a> {
556
513
///
557
514
/// Please note that PureEdDSA (Ed25519 and Ed448 keys) do not support streaming.
558
515
/// 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 ) ]
563
517
pub fn update ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , ErrorStack > {
564
518
unsafe {
565
519
cvt ( ffi:: EVP_DigestUpdate (
@@ -572,10 +526,7 @@ impl<'a> Verifier<'a> {
572
526
}
573
527
574
528
/// 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 ) ]
579
530
pub fn verify ( & self , signature : & [ u8 ] ) -> Result < bool , ErrorStack > {
580
531
unsafe {
581
532
let r =
@@ -592,10 +543,7 @@ impl<'a> Verifier<'a> {
592
543
}
593
544
594
545
/// 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 ) ]
599
547
#[ cfg( any( ossl111, boringssl, libressl370) ) ]
600
548
pub fn verify_oneshot ( & mut self , signature : & [ u8 ] , buf : & [ u8 ] ) -> Result < bool , ErrorStack > {
601
549
unsafe {
0 commit comments