summaryrefslogtreecommitdiffstats
path: root/.gitignore
AgeCommit message (Expand)Author
2016-08-02Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/k...Linus Torvalds
2016-07-22scripts: add Linux .cocciconfig for coccinelleLuis R. Rodriguez
2016-06-07GCC plugin infrastructureEmese Revfy
2016-04-28gitignore: fix wordingKyeongmin Cho
2015-09-08Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/k...Linus Torvalds
2015-08-28.gitignore: add *.su patternRasmus Villemoes
2015-08-07modsign: Use single PEM file for autogenerated keyDavid Woodhouse
2015-06-15Kbuild: Add ID files to .gitignoreAndi Kleen
2015-06-15gitignore: Add MIPS vmlinux.32 to the listFlorian Fainelli
2015-04-17.gitignore: ignore *.tarAndrey Skvortsov
2015-02-17scripts/gdb: ignore byte-compiled python filesDaniel Thompson
2015-02-12gitignore: ignore tar-install build directoryAndrey Skvortsov
2014-11-25.gitignore: Add Kdevelop4 project filesBoaz Harrosh
2014-07-30kbuild: Support split debug info v4Andi Kleen
2014-04-16.gitignore: ignore Module.symvers in all directoriesZhao, Gang
2014-02-10gitignore: add all.configBorislav Petkov
2013-07-31.gitignore: ignore *.lz4 filesMarkus Trippelsdorf
2012-12-17.gitignore: remove stale entry for generated version.hJonathan Austin
2012-10-19MODSIGN: Cleanup .gitignoreDavid Howells
2012-10-10MODSIGN: Provide gitignore and make clean rules for extra filesDavid Howells
2011-07-01gitignore: ignore debian build directoryGreg Dietsche
2011-04-28kbuild: asm-generic supportSam Ravnborg
2011-02-22.gitignore: ignore *.xz filesRomain Francoise
2010-06-01Merge branch 'for-35' of git://repo.or.cz/linux-kbuildLinus Torvalds
2010-03-23.gitignore: ignore *.lzo filesPhilipp Kohlbecher
2010-03-12Fix up .gitignore for top-level file patternsLinus Torvalds
2010-03-06um: tell git to ignore generated filesWANG Cong
2010-01-11.gitignore: ignore vmlinuzFlorian Fainelli
2009-12-12kbuild: generate modules.builtinMichal Marek
2009-12-12kbuild: move utsrelease.h to include/generatedSam Ravnborg
2009-12-12kbuild: move autoconf.h to include/generatedSam Ravnborg
2009-12-12kbuild: move compile.h to include/generatedSam Ravnborg
2009-12-12kbuild: drop include/asmSam Ravnborg
2009-12-12kbuild: move asm-offsets.h to include/generatedSam Ravnborg
2009-12-12kbuild: move bounds.h to include/generatedSam Ravnborg
2009-11-30.gitignore: Add bzip2 compressed filesGertjan van Wingerde
2009-06-27gitignore: ignore gcov output filesAmerigo Wang
2009-06-14Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/sam/kb...Linus Torvalds
2009-06-14.gitignore: ignore *.lzma filesArne Janbu
2009-06-14gitignore: Add GNU GLOBAL files to top .gitignoreJani Nikula
2009-06-12trivial: Remove the hyphen from git commandsMatt Kraai
2009-06-09ignore *.patch filesMike Frysinger
2009-04-19kbuild: support include/generatedSam Ravnborg
2008-06-29Fix and clean top .gitignoreEduard - Gabriel Munteanu
2008-06-17Unignore vmlinux.lds.h from Git.Eduard - Gabriel Munteanu
2008-05-25.gitignore: match ncscope.outJike Song
2008-05-11Remove *.rej pattern from .gitignoreS.Çağlar Onur
2008-04-30Update .gitignore to include include/linux/bounds.hTheodore Ts'o
2008-04-25Update .gitignore filesMatthew Wilcox
2008-03-04.gitignore: ignore emacs backup and temporary files.Chris Dearman
6' href='#n286'>286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915
/*
 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

/*
 * Low level APIs are deprecated for public use, but still ok for internal use.
 */
#include "internal/deprecated.h"

#include <ctype.h>

#include <openssl/core.h>
#include <openssl/core_dispatch.h>
#include <openssl/core_names.h>
#include <openssl/bn.h>
#include <openssl/err.h>
#include <openssl/safestack.h>
#include <openssl/proverr.h>
#include "internal/ffc.h"
#include "crypto/bn.h"           /* bn_get_words() */
#include "crypto/dh.h"           /* ossl_dh_get0_params() */
#include "crypto/dsa.h"          /* ossl_dsa_get0_params() */
#include "crypto/ec.h"           /* ossl_ec_key_get_libctx */
#include "crypto/ecx.h"          /* ECX_KEY, etc... */
#include "crypto/rsa.h"          /* RSA_PSS_PARAMS_30, etc... */
#include "prov/bio.h"
#include "prov/implementations.h"
#include "endecoder_local.h"

DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM)

# ifdef SIXTY_FOUR_BIT_LONG
#  define BN_FMTu "%lu"
#  define BN_FMTx "%lx"
# endif

# ifdef SIXTY_FOUR_BIT
#  define BN_FMTu "%llu"
#  define BN_FMTx "%llx"
# endif

# ifdef THIRTY_TWO_BIT
#  define BN_FMTu "%u"
#  define BN_FMTx "%x"
# endif

static int print_labeled_bignum(BIO *out, const char *label, const BIGNUM *bn)
{
    int ret = 0, use_sep = 0;
    char *hex_str = NULL, *p;
    const char spaces[] = "    ";
    const char *post_label_spc = " ";

    const char *neg = "";
    int bytes;

    if (bn == NULL)
        return 0;
    if (label == NULL) {
        label = "";
        post_label_spc = "";
    }

    if (BN_is_zero(bn))
        return BIO_printf(out, "%s%s0\n", label, post_label_spc);

    if (BN_num_bytes(bn) <= BN_BYTES) {
        BN_ULONG *words = bn_get_words(bn);

        if (BN_is_negative(bn))
            neg = "-";

        return BIO_printf(out, "%s%s%s" BN_FMTu " (%s0x" BN_FMTx ")\n",
                          label, post_label_spc, neg, words[0], neg, words[0]);
    }

    hex_str = BN_bn2hex(bn);
    p = hex_str;
    if (*p == '-') {
        ++p;
        neg = " (Negative)";
    }
    if (BIO_printf(out, "%s%s\n", label, neg) <= 0)
        goto err;

    /* Keep track of how many bytes we have printed out so far */
    bytes = 0;

    if (BIO_printf(out, "%s", spaces) <= 0)
        goto err;

    /* Add a leading 00 if the top bit is set */
    if (*p >= '8') {
        if (BIO_printf(out, "%02x", 0) <= 0)
            goto err;
        ++bytes;
        use_sep = 1;
    }
    while (*p != '\0') {
        /* Do a newline after every 15 hex bytes + add the space indent */
        if ((bytes % 15) == 0 && bytes > 0) {
            if (BIO_printf(out, ":\n%s", spaces) <= 0)
                goto err;
            use_sep = 0; /* The first byte on the next line doesnt have a : */
        }
        if (BIO_printf(out, "%s%c%c", use_sep ? ":" : "",
                       tolower(p[0]), tolower(p[1])) <= 0)
            goto err;
        ++bytes;
        p += 2;
        use_sep = 1;
    }
    if (BIO_printf(out, "\n") <= 0)
        goto err;
    ret = 1;
err:
    OPENSSL_free(hex_str);
    return ret;
}

/* Number of octets per line */
#define LABELED_BUF_PRINT_WIDTH    15

#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
static int print_labeled_buf(BIO *out, const char *label,
                             const unsigned char *buf, size_t buflen)
{
    size_t i;

    if (BIO_printf(out, "%s\n", label) <= 0)
        return 0;

    for (i = 0; i < buflen; i++) {
        if ((i % LABELED_BUF_PRINT_WIDTH) == 0) {
            if (i > 0 && BIO_printf(out, "\n") <= 0)
                return 0;
            if (