Changeset 726 in openpam


Ignore:
Timestamp:
Aug 21, 2013, 3:14:02 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Use a dummy bit in the key structure instead of relying on the label.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/security/oath_types.h

    r693 r726  
    4545
    4646        /* housekeeping */
     47        unsigned int     dummy:1;
    4748        unsigned int     mapped:1;
    4849        unsigned int     locked:1;
  • trunk/lib/liboath/oath_hotp.c

    r693 r726  
    118118{
    119119        unsigned int code;
    120         int dummy;
    121120
    122121        if (k == NULL)
     
    128127        if (k->counter >= UINT64_MAX - window)
    129128                return (-1);
    130         dummy = (strcmp(k->label, OATH_DUMMY_LABEL) == 0);
    131129        for (int i = 0; i < window; ++i) {
    132130                code = oath_hotp(k->key, k->keylen, k->counter + i, k->digits);
    133                 if (code == response && !dummy) {
     131                if (code == response && !k->dummy) {
    134132                        k->counter = k->counter + i;
    135133                        return (1);
  • trunk/lib/liboath/oath_key_dummy.c

    r725 r726  
    5252        if ((key = oath_key_alloc()) == NULL)
    5353                return (NULL);
     54        key->dummy = 1;
    5455        key->mode = mode;
    5556        key->digits = digits;
     
    5758        key->timestep = 30;
    5859        key->hash = hash;
    59         strcpy(key->label, OATH_DUMMY_LABEL);
    60         key->labellen = strlen(key->label);
     60        memcpy(key->label, OATH_DUMMY_LABEL, sizeof OATH_DUMMY_LABEL);
     61        key->labellen = sizeof OATH_DUMMY_LABEL - 1;
    6162        key->keylen = sizeof key->key;
    6263        return (key);
  • trunk/lib/liboath/oath_totp.c

    r693 r726  
    7878        unsigned int code;
    7979        uint64_t seq;
    80         int dummy;
    8180
    8281        if (k == NULL)
     
    8988                return (-1);
    9089        seq = time(NULL) / k->timestep;
    91         dummy = (strcmp(k->label, OATH_DUMMY_LABEL) == 0);
    9290        for (int i = -window; i <= window; ++i) {
    9391#if OATH_TOTP_PREVENT_REUSE
     
    9795#endif
    9896                code = oath_hotp(k->key, k->keylen, seq + i, k->digits);
    99                 if (code == response && !dummy) {
     97                if (code == response && !k->dummy) {
    10098                        k->lastuse = seq;
    10199                        return (1);
Note: See TracChangeset for help on using the changeset viewer.