~ubuntu-branches/debian/stretch/dropbear/stretch

« back to all changes in this revision

Viewing changes to keyimport.c

  • Committer: Package Import Robot
  • Author(s): Guilhem Moulin, Matt Johnston, Guilhem Moulin
  • Date: 2015-10-03 20:47:33 UTC
  • mfrom: (1.4.9)
  • Revision ID: package-import@ubuntu.com-20151003204733-4ututwekmkdnczsu
Tags: 2015.68-1
* New co-maintainer.

[ Matt Johnston ]
* New upstream release.  (Closes: #631858, #775222.)

[ Guilhem Moulin ]
* debian/source/format: 3.0 (quilt)
* debian/compat: 9
* debian/control:
  + Bump Standards-Version to 3.9.6 (no changes necessary).
  + Add Homepage, Vcs-Git, and Vcs-Browser fields.
* debian/copyright: add machine-readable file.
* Split up package in dropbear-bin (binaries), dropbear-run (init scripts)
  and dropbear-initramfs (initramfs integration).  'dropbear' is now a
  transitional dummy package depending on on dropbear-run and
  dropbear-initramfs.  (Closes: #692932.)
* Refactor the package using dh_* tools, including dh_autoreconf.  (Closes:
  #689618, #777324, #793006, #793917.)
* Add 'Multi-Arch: foreign' tags.
* dropbear-run:
  + Add a status option to the /etc/init.d script.
  + Pass key files with -r not -d in /etc/init.d script.  (Closes: #761143.)
  + Post-installation script: Generate missing ECDSA in addition to RSA and
    DSS host keys.  (Closes: #776976.)
* dropbear-initramfs:
  + No longer mark /usr/share/initramfs-tools/conf-hooks.d/dropbear as a
    configuration file, since it violates the Debian Policy Manual section
    10.7.2.  (Regression from 2014.64-1.)  Instead, move the file to
    /etc/initramfs-tools/conf-hooks.d/dropbear and add a symlink in
    /usr/share/initramfs-tools/conf-hooks.d.
  + Delete debian/initramfs/premount-devpts, since /dev/pts in mounted by
    init since initramfs-tools 0.94.  (Closes: #632656, #797939.)
  + Auto-generate host keys in the postinstall script, not when runing
    update-initramfs.  Pass the '-R' option (via $PKGOPTION_dropbear_OPTION)
    for the old behavior.  Also, print fingerprint and ASCII art for
    generated keys (if ssh-keygen is available).
  + Revert ad2fb1c and remove warning about changing host key.  Users
    shouldn't be encouraged to use the same keys in the encrypted partition
    and in the initramfs.  The proper fix is to use an alternative port or
    UserKnownHostFile.
  + Set ~root to `mktemp -d "$DESTDIR/root-XXXXXX"` to avoid collisions with
    $rootmnt.  (Closes: #558115.)
  + Exit gracefully if $IP is 'none' or 'off'.  (Closes: #692932.)
  + Start dropbear with flag -s to explicitly disable password logins.
  + Terminate all children before killing dropbear, to avoid stalled SSH
    connections.  (Closes: #735203.)
  + Run configure_networking in the foreground.  (Closes: #584780, #626181,
    #739519.)
  + Bring down interfaces and flush IP routes and addresses before exiting
    the ramdisk, to avoid dirty network configuration in the regular kernel.
    (Closes: #715048, #720987, #720988.)  The interfaces considered are
    those matching the $DROPBEAR_IFDOWN shell pattern (default: '*'); the
    special value 'none' keeps all interfaces up and preserves routing
    tables and addresses.

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
static void base64_encode_fp(FILE * fp, unsigned char *data,
194
194
                int datalen, int cpl)
195
195
{
196
 
    char out[100];
 
196
        unsigned char out[100];
197
197
    int n;
198
198
        unsigned long outlen;
199
199
        int rawcpl;
445
445
                                                ret->keyblob_size);
446
446
                        }
447
447
                        outlen = ret->keyblob_size - ret->keyblob_len;
448
 
                        if (base64_decode(buffer, len, 
 
448
                        if (base64_decode((const unsigned char *)buffer, len,
449
449
                                                ret->keyblob + ret->keyblob_len, &outlen) != CRYPT_OK){
450
450
                                errmsg = "Error decoding base64";
451
451
                                goto error;
464
464
                goto error;
465
465
        }
466
466
 
467
 
        memset(buffer, 0, sizeof(buffer));
 
467
        m_burn(buffer, sizeof(buffer));
468
468
        return ret;
469
469
 
470
470
        error:
471
 
        memset(buffer, 0, sizeof(buffer));
 
471
        m_burn(buffer, sizeof(buffer));
472
472
        if (ret) {
473
473
                if (ret->keyblob) {
474
 
                        memset(ret->keyblob, 0, ret->keyblob_size);
 
474
                        m_burn(ret->keyblob, ret->keyblob_size);
475
475
                        m_free(ret->keyblob);
476
476
                }
477
 
                memset(&ret, 0, sizeof(ret));
478
477
                m_free(ret);
479
478
        }
480
479
        if (fp) {
494
493
        if (!key)
495
494
                return 0;
496
495
        ret = key->encrypted;
497
 
        memset(key->keyblob, 0, key->keyblob_size);
 
496
        m_burn(key->keyblob, key->keyblob_size);
498
497
        m_free(key->keyblob);
499
 
        memset(&key, 0, sizeof(key));
500
498
        m_free(key);
501
499
        return ret;
502
500
}
509
507
        int i, num_integers = 0;
510
508
        sign_key *retval = NULL;
511
509
        char *errmsg;
512
 
        char *modptr = NULL;
 
510
        unsigned char *modptr = NULL;
513
511
        int modlen = -9999;
514
512
        enum signkey_type type;
515
513
 
627
625
 
628
626
                if (i == 0) {
629
627
                        /* First integer is a version indicator */
630
 
                        int expected;
 
628
                        int expected = -1;
631
629
                        switch (key->type) {
632
630
                                case OSSH_RSA:
633
631
                                case OSSH_DSA:
648
646
                         */
649
647
                        if (i == 1) {
650
648
                                /* Save the details for after we deal with number 2. */
651
 
                                modptr = (char *)p;
 
649
                                modptr = p;
652
650
                                modlen = len;
653
651
                        } else if (i >= 2 && i <= 5) {
654
 
                                buf_putstring(blobbuf, p, len);
 
652
                                buf_putstring(blobbuf, (const char*)p, len);
655
653
                                if (i == 2) {
656
 
                                        buf_putstring(blobbuf, modptr, modlen);
 
654
                                        buf_putstring(blobbuf, (const char*)modptr, modlen);
657
655
                                }
658
656
                        }
659
657
                } else if (key->type == OSSH_DSA) {
661
659
                         * OpenSSH key order is p, q, g, y, x,
662
660
                         * we want the same.
663
661
                         */
664
 
                        buf_putstring(blobbuf, p, len);
 
662
                        buf_putstring(blobbuf, (const char*)p, len);
665
663
                }
666
664
 
667
665
                /* Skip past the number. */
810
808
        }
811
809
        m_burn(key->keyblob, key->keyblob_size);
812
810
        m_free(key->keyblob);
813
 
        m_burn(key, sizeof(key));
 
811
        m_burn(key, sizeof(*key));
814
812
        m_free(key);
815
813
        if (errmsg) {
816
814
                fprintf(stderr, "Error: %s\n", errmsg);
826
824
        unsigned char *outblob = NULL;
827
825
        int outlen = -9999;
828
826
        struct mpint_pos numbers[9];
829
 
        int nnumbers = -1, pos, len, seqlen, i;
 
827
        int nnumbers = -1, pos = 0, len = 0, seqlen, i;
830
828
        char *header = NULL, *footer = NULL;
831
829
        char zero[1];
832
830
        int ret = 0;
1045
1043
                int curve_oid_len = 0;
1046
1044
                const void* curve_oid = NULL;
1047
1045
                unsigned long pubkey_size = 2*curve_size+1;
1048
 
                unsigned int k_size;
 
1046
                int k_size;
 
1047
                int err = 0;
1049
1048
 
1050
1049
                /* version. less than 10 bytes */
1051
1050
                buf_incrwritepos(seq_buf,
1091
1090
                buf_incrwritepos(seq_buf,
1092
1091
                        ber_write_id_len(buf_getwriteptr(seq_buf, 10), 3, 1+pubkey_size, 0));
1093
1092
                buf_putbyte(seq_buf, 0);
1094
 
                int err = ecc_ansi_x963_export(*eck, buf_getwriteptr(seq_buf, pubkey_size), &pubkey_size);
 
1093
                err = ecc_ansi_x963_export(*eck, buf_getwriteptr(seq_buf, pubkey_size), &pubkey_size);
1095
1094
                if (err != CRYPT_OK) {
1096
1095
                        dropbear_exit("ECC error");
1097
1096
                }