diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/man/bn_dump.3 | 317 |
1 files changed, 17 insertions, 300 deletions
diff --git a/src/lib/libcrypto/man/bn_dump.3 b/src/lib/libcrypto/man/bn_dump.3 index cfe707b775..b4272441e5 100644 --- a/src/lib/libcrypto/man/bn_dump.3 +++ b/src/lib/libcrypto/man/bn_dump.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: bn_dump.3,v 1.8 2023/01/20 12:16:46 jsing Exp $ | 1 | .\" $OpenBSD: bn_dump.3,v 1.9 2023/11/16 18:10:19 schwarze Exp $ |
| 2 | .\" full merge up to: | 2 | .\" full merge up to: |
| 3 | .\" OpenSSL crypto/bn/README.pod aebb9aac Jul 19 09:27:53 2016 -0400 | 3 | .\" OpenSSL crypto/bn/README.pod aebb9aac Jul 19 09:27:53 2016 -0400 |
| 4 | .\" | 4 | .\" |
| @@ -50,7 +50,7 @@ | |||
| 50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
| 52 | .\" | 52 | .\" |
| 53 | .Dd $Mdocdate: January 20 2023 $ | 53 | .Dd $Mdocdate: November 16 2023 $ |
| 54 | .Dt BN_DUMP 3 | 54 | .Dt BN_DUMP 3 |
| 55 | .Os | 55 | .Os |
| 56 | .Sh NAME | 56 | .Sh NAME |
| @@ -64,28 +64,12 @@ | |||
| 64 | .Nm bn_mul_comba8 , | 64 | .Nm bn_mul_comba8 , |
| 65 | .Nm bn_sqr_comba4 , | 65 | .Nm bn_sqr_comba4 , |
| 66 | .Nm bn_sqr_comba8 , | 66 | .Nm bn_sqr_comba8 , |
| 67 | .Nm bn_cmp_words , | ||
| 68 | .Nm bn_mul_normal , | 67 | .Nm bn_mul_normal , |
| 69 | .Nm bn_mul_recursive , | ||
| 70 | .Nm bn_mul_part_recursive , | ||
| 71 | .Nm bn_sqr_normal , | ||
| 72 | .Nm bn_sqr_recursive , | ||
| 73 | .Nm bn_expand , | 68 | .Nm bn_expand , |
| 74 | .Nm bn_wexpand , | 69 | .Nm bn_wexpand |
| 75 | .Nm bn_expand2 , | ||
| 76 | .Nm bn_fix_top , | ||
| 77 | .Nm bn_check_top , | ||
| 78 | .Nm bn_print , | ||
| 79 | .Nm bn_dump , | ||
| 80 | .Nm bn_set_max , | ||
| 81 | .Nm bn_set_high , | ||
| 82 | .Nm bn_set_low , | ||
| 83 | .Nm mul , | ||
| 84 | .Nm mul_add , | ||
| 85 | .Nm sqr | ||
| 86 | .Nd BIGNUM library internal functions | 70 | .Nd BIGNUM library internal functions |
| 87 | .Sh SYNOPSIS | 71 | .Sh SYNOPSIS |
| 88 | .In openssl/bn.h | 72 | .Fd #include "bn_local.h" |
| 89 | .Ft BN_ULONG | 73 | .Ft BN_ULONG |
| 90 | .Fo bn_mul_words | 74 | .Fo bn_mul_words |
| 91 | .Fa "BN_ULONG *rp" | 75 | .Fa "BN_ULONG *rp" |
| @@ -148,12 +132,6 @@ | |||
| 148 | .Fa "BN_ULONG *r" | 132 | .Fa "BN_ULONG *r" |
| 149 | .Fa "BN_ULONG *a" | 133 | .Fa "BN_ULONG *a" |
| 150 | .Fc | 134 | .Fc |
| 151 | .Ft int | ||
| 152 | .Fo bn_cmp_words | ||
| 153 | .Fa "BN_ULONG *a" | ||
| 154 | .Fa "BN_ULONG *b" | ||
| 155 | .Fa "int n" | ||
| 156 | .Fc | ||
| 157 | .Ft void | 135 | .Ft void |
| 158 | .Fo bn_mul_normal | 136 | .Fo bn_mul_normal |
| 159 | .Fa "BN_ULONG *r" | 137 | .Fa "BN_ULONG *r" |
| @@ -162,60 +140,6 @@ | |||
| 162 | .Fa "BN_ULONG *b" | 140 | .Fa "BN_ULONG *b" |
| 163 | .Fa "int nb" | 141 | .Fa "int nb" |
| 164 | .Fc | 142 | .Fc |
| 165 | .Ft void | ||
| 166 | .Fo bn_mul_recursive | ||
| 167 | .Fa "BN_ULONG *r" | ||
| 168 | .Fa "BN_ULONG *a" | ||
| 169 | .Fa "BN_ULONG *b" | ||
| 170 | .Fa "int n2" | ||
| 171 | .Fa "int dna" | ||
| 172 | .Fa "int dnb" | ||
| 173 | .Fa "BN_ULONG *tmp" | ||
| 174 | .Fc | ||
| 175 | .Ft void | ||
| 176 | .Fo bn_mul_part_recursive | ||
| 177 | .Fa "BN_ULONG *r" | ||
| 178 | .Fa "BN_ULONG *a" | ||
| 179 | .Fa "BN_ULONG *b" | ||
| 180 | .Fa "int n" | ||
| 181 | .Fa "int tna" | ||
| 182 | .Fa "int tnb" | ||
| 183 | .Fa "BN_ULONG *tmp" | ||
| 184 | .Fc | ||
| 185 | .Ft void | ||
| 186 | .Fo bn_sqr_normal | ||
| 187 | .Fa "BN_ULONG *r" | ||
| 188 | .Fa "BN_ULONG *a" | ||
| 189 | .Fa "int n" | ||
| 190 | .Fa "BN_ULONG *tmp" | ||
| 191 | .Fc | ||
| 192 | .Ft void | ||
| 193 | .Fo bn_sqr_recursive | ||
| 194 | .Fa "BN_ULONG *r" | ||
| 195 | .Fa "BN_ULONG *a" | ||
| 196 | .Fa "int n2" | ||
| 197 | .Fa "BN_ULONG *tmp" | ||
| 198 | .Fc | ||
| 199 | .Ft void | ||
| 200 | .Fo mul | ||
| 201 | .Fa "BN_ULONG r" | ||
| 202 | .Fa "BN_ULONG a" | ||
| 203 | .Fa "BN_ULONG w" | ||
| 204 | .Fa "BN_ULONG c" | ||
| 205 | .Fc | ||
| 206 | .Ft void | ||
| 207 | .Fo mul_add | ||
| 208 | .Fa "BN_ULONG r" | ||
| 209 | .Fa "BN_ULONG a" | ||
| 210 | .Fa "BN_ULONG w" | ||
| 211 | .Fa "BN_ULONG c" | ||
| 212 | .Fc | ||
| 213 | .Ft void | ||
| 214 | .Fo sqr | ||
| 215 | .Fa "BN_ULONG r0" | ||
| 216 | .Fa "BN_ULONG r1" | ||
| 217 | .Fa "BN_ULONG a" | ||
| 218 | .Fc | ||
| 219 | .Ft BIGNUM * | 143 | .Ft BIGNUM * |
| 220 | .Fo bn_expand | 144 | .Fo bn_expand |
| 221 | .Fa "BIGNUM *a" | 145 | .Fa "BIGNUM *a" |
| @@ -226,46 +150,8 @@ | |||
| 226 | .Fa "BIGNUM *a" | 150 | .Fa "BIGNUM *a" |
| 227 | .Fa "int n" | 151 | .Fa "int n" |
| 228 | .Fc | 152 | .Fc |
| 229 | .Ft BIGNUM * | ||
| 230 | .Fo bn_expand2 | ||
| 231 | .Fa "BIGNUM *a" | ||
| 232 | .Fa "int n" | ||
| 233 | .Fc | ||
| 234 | .Ft void | ||
| 235 | .Fo bn_fix_top | ||
| 236 | .Fa "BIGNUM *a" | ||
| 237 | .Fc | ||
| 238 | .Ft void | ||
| 239 | .Fo bn_check_top | ||
| 240 | .Fa "BIGNUM *a" | ||
| 241 | .Fc | ||
| 242 | .Ft void | ||
| 243 | .Fo bn_print | ||
| 244 | .Fa "BIGNUM *a" | ||
| 245 | .Fc | ||
| 246 | .Ft void | ||
| 247 | .Fo bn_dump | ||
| 248 | .Fa "BN_ULONG *d" | ||
| 249 | .Fa "int n" | ||
| 250 | .Fc | ||
| 251 | .Ft void | ||
| 252 | .Fo bn_set_max | ||
| 253 | .Fa "BIGNUM *a" | ||
| 254 | .Fc | ||
| 255 | .Ft void | ||
| 256 | .Fo bn_set_high | ||
| 257 | .Fa "BIGNUM *r" | ||
| 258 | .Fa "BIGNUM *a" | ||
| 259 | .Fa "int n" | ||
| 260 | .Fc | ||
| 261 | .Ft void | ||
| 262 | .Fo bn_set_low | ||
| 263 | .Fa "BIGNUM *r" | ||
| 264 | .Fa "BIGNUM *a" | ||
| 265 | .Fa "int n" | ||
| 266 | .Fc | ||
| 267 | .Sh DESCRIPTION | 153 | .Sh DESCRIPTION |
| 268 | This page documents the internal functions used by the OpenSSL | 154 | This page documents some internal functions used by the |
| 269 | .Vt BIGNUM | 155 | .Vt BIGNUM |
| 270 | implementation. | 156 | implementation. |
| 271 | They are described here to facilitate debugging and extending the | 157 | They are described here to facilitate debugging and extending the |
| @@ -327,16 +213,12 @@ is a bit field of flags which are defined in | |||
| 327 | .In openssl/bn.h . | 213 | .In openssl/bn.h . |
| 328 | The flags begin with | 214 | The flags begin with |
| 329 | .Dv BN_FLG_ . | 215 | .Dv BN_FLG_ . |
| 330 | The macros | 216 | The functions |
| 331 | .Fn BN_set_flags b n | 217 | .Xr BN_set_flags 3 |
| 332 | and | 218 | and |
| 333 | .Fn BN_get_flags b n | 219 | .Xr BN_get_flags 3 |
| 334 | exist to enable or fetch flag(s) | 220 | enable or inspect |
| 335 | .Fa n | 221 | .Fa flags . |
| 336 | from a | ||
| 337 | .Vt BIGNUM | ||
| 338 | structure | ||
| 339 | .Fa b . | ||
| 340 | .Pp | 222 | .Pp |
| 341 | Various routines in this library require the use of temporary | 223 | Various routines in this library require the use of temporary |
| 342 | .Vt BIGNUM | 224 | .Vt BIGNUM |
| @@ -488,18 +370,6 @@ and the 16 word array | |||
| 488 | .Pp | 370 | .Pp |
| 489 | The following functions are implemented in C: | 371 | The following functions are implemented in C: |
| 490 | .Pp | 372 | .Pp |
| 491 | .Fn bn_cmp_words a b n | ||
| 492 | operates on the | ||
| 493 | .Fa n | ||
| 494 | word arrays | ||
| 495 | .Fa a | ||
| 496 | and | ||
| 497 | .Fa b . | ||
| 498 | It returns 1, 0 and -1 if | ||
| 499 | .Fa a | ||
| 500 | is greater than, equal and less than | ||
| 501 | .Fa b . | ||
| 502 | .Pp | ||
| 503 | .Fn bn_mul_normal r a na b nb | 373 | .Fn bn_mul_normal r a na b nb |
| 504 | operates on the | 374 | operates on the |
| 505 | .Fa na | 375 | .Fa na |
| @@ -518,103 +388,15 @@ It computes | |||
| 518 | and places the result in | 388 | and places the result in |
| 519 | .Fa r . | 389 | .Fa r . |
| 520 | .Pp | 390 | .Pp |
| 521 | .Fn bn_mul_recursive r a b n2 dna dnb t | ||
| 522 | operates on the word arrays | ||
| 523 | .Fa a | ||
| 524 | and | ||
| 525 | .Fa b | ||
| 526 | of length | ||
| 527 | .Fa n2 Ns + Ns Fa dna | ||
| 528 | and | ||
| 529 | .Fa n2 Ns + Ns Fa dnb | ||
| 530 | .Pf ( Fa dna | ||
| 531 | and | ||
| 532 | .Fa dnb | ||
| 533 | are currently allowed to be 0 or negative) and the | ||
| 534 | .Pf 2* Fa n2 | ||
| 535 | word arrays | ||
| 536 | .Fa r | ||
| 537 | and | ||
| 538 | .Sy t . | ||
| 539 | .Fa n2 | ||
| 540 | must be a power of 2. | ||
| 541 | It computes | ||
| 542 | .Fa a Ns * Ns Fa b | ||
| 543 | and places the result in | ||
| 544 | .Fa r . | ||
| 545 | .Pp | ||
| 546 | .Fn bn_mul_part_recursive r a b n tna tnb tmp | ||
| 547 | operates on the word arrays | ||
| 548 | .Fa a | ||
| 549 | and | ||
| 550 | .Fa b | ||
| 551 | of length | ||
| 552 | .Fa n Ns + Ns Fa tna | ||
| 553 | and | ||
| 554 | .Fa n Ns + Ns Fa tnb | ||
| 555 | and the | ||
| 556 | .Pf 4* Fa n | ||
| 557 | word arrays | ||
| 558 | .Fa r | ||
| 559 | and | ||
| 560 | .Fa tmp . | ||
| 561 | .Pp | ||
| 562 | .Xr BN_mul 3 | 391 | .Xr BN_mul 3 |
| 563 | calls | 392 | calls |
| 564 | .Fn bn_mul_normal , | 393 | .Fn bn_mul_comba4 |
| 565 | or an optimized implementation if the factors have the same size: | 394 | if both factors are 4 words long, |
| 566 | .Fn bn_mul_comba8 | 395 | .Fn bn_mul_comba8 |
| 567 | is used if they are 8 words long, | 396 | if both factors are 8 words long, |
| 568 | .Fn bn_mul_recursive | 397 | or |
| 569 | if they are larger than | 398 | .Fn bn_mul_normal |
| 570 | .Dv BN_MULL_SIZE_NORMAL | 399 | otherwise. |
| 571 | and the size is an exact multiple of the word size, and | ||
| 572 | .Fn bn_mul_part_recursive | ||
| 573 | for others that are larger than | ||
| 574 | .Dv BN_MULL_SIZE_NORMAL . | ||
| 575 | .Pp | ||
| 576 | .Fn bn_sqr_normal r a n tmp | ||
| 577 | operates on the | ||
| 578 | .Fa n | ||
| 579 | word array | ||
| 580 | .Fa a | ||
| 581 | and the | ||
| 582 | .Pf 2* Fa n | ||
| 583 | word arrays | ||
| 584 | .Fa tmp | ||
| 585 | and | ||
| 586 | .Fa r . | ||
| 587 | .Pp | ||
| 588 | The implementations use the following macros which, depending on the | ||
| 589 | architecture, may use | ||
| 590 | .Vt long long | ||
| 591 | C operations or inline assembler. | ||
| 592 | They are defined in | ||
| 593 | .Pa bn_lcl.h . | ||
| 594 | .Pp | ||
| 595 | .Fn mul r a w c | ||
| 596 | computes | ||
| 597 | .Fa w Ns * Ns Fa a Ns + Ns Fa c | ||
| 598 | and places the low word of the result in | ||
| 599 | .Fa r | ||
| 600 | and the high word in | ||
| 601 | .Fa c . | ||
| 602 | .Pp | ||
| 603 | .Fn mul_add r a w c | ||
| 604 | computes | ||
| 605 | .Fa w Ns * Ns Fa a Ns + Ns Fa r Ns + Ns Fa c | ||
| 606 | and places the low word of the result in | ||
| 607 | .Fa r | ||
| 608 | and the high word in | ||
| 609 | .Fa c . | ||
| 610 | .Pp | ||
| 611 | .Fn sqr r0 r1 a | ||
| 612 | computes | ||
| 613 | .Fa a Ns * Ns Fa a | ||
| 614 | and places the low word of the result in | ||
| 615 | .Fa r0 | ||
| 616 | and the high word in | ||
| 617 | .Fa r1 . | ||
| 618 | .Ss Size changes | 400 | .Ss Size changes |
| 619 | .Fn bn_expand | 401 | .Fn bn_expand |
| 620 | ensures that | 402 | ensures that |
| @@ -628,71 +410,6 @@ ensures that | |||
| 628 | has enough space for an | 410 | has enough space for an |
| 629 | .Fa n | 411 | .Fa n |
| 630 | word number. | 412 | word number. |
| 631 | If the number has to be expanded, both macros call | 413 | They return 0 on error or 1 otherwise. |
| 632 | .Fn bn_expand2 , | ||
| 633 | which allocates a new | ||
| 634 | .Fa d | ||
| 635 | array and copies the data. | ||
| 636 | They return | ||
| 637 | .Dv NULL | ||
| 638 | on error, | ||
| 639 | .Fa b | ||
| 640 | otherwise. | ||
| 641 | .Pp | ||
| 642 | The | ||
| 643 | .Fn bn_fix_top | ||
| 644 | macro reduces | ||
| 645 | .Fa a Ns -> Ns Fa top | ||
| 646 | to point to the most significant non-zero word plus one when | ||
| 647 | .Fa a | ||
| 648 | has shrunk. | ||
| 649 | .Ss Debugging | ||
| 650 | .Fn bn_check_top | ||
| 651 | verifies that | ||
| 652 | .Ql ((a)-\(ratop \(ra= 0 && (a)-\(ratop \(la= (a)-\(radmax) . | ||
| 653 | A violation will cause the program to abort. | ||
| 654 | .Pp | ||
| 655 | .Fn bn_print | ||
| 656 | prints | ||
| 657 | .Fa a | ||
| 658 | to | ||
| 659 | .Dv stderr . | ||
| 660 | .Fn bn_dump | ||
| 661 | prints | ||
| 662 | .Fa n | ||
| 663 | words at | ||
| 664 | .Fa d | ||
| 665 | (in reverse order, i.e.\& | ||
| 666 | most significant word first) to | ||
| 667 | .Dv stderr . | ||
| 668 | .Pp | ||
| 669 | .Fn bn_set_max | ||
| 670 | makes | ||
| 671 | .Fa a | ||
| 672 | a static number with a | ||
| 673 | .Fa dmax | ||
| 674 | of its current size. | ||
| 675 | This is used by | ||
| 676 | .Fn bn_set_low | ||
| 677 | and | ||
| 678 | .Fn bn_set_high | ||
| 679 | to make | ||
| 680 | .Fa r | ||
| 681 | a read-only | ||
| 682 | .Vt BIGNUM | ||
| 683 | that contains the | ||
| 684 | .Fa n | ||
| 685 | low or high words of | ||
| 686 | .Fa a . | ||
| 687 | .Pp | ||
| 688 | If | ||
| 689 | .Dv BN_DEBUG | ||
| 690 | is not defined, | ||
| 691 | .Fn bn_check_top , | ||
| 692 | .Fn bn_print , | ||
| 693 | .Fn bn_dump | ||
| 694 | and | ||
| 695 | .Fn bn_set_max | ||
| 696 | are defined as empty macros. | ||
| 697 | .Sh SEE ALSO | 414 | .Sh SEE ALSO |
| 698 | .Xr BN_new 3 | 415 | .Xr BN_new 3 |
