Changeset 679 in openpam


Ignore:
Timestamp:
Mar 18, 2013, 9:38:58 PM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

Clean up and simplify dummy key handling.

Location:
trunk
Files:
5 edited

Legend:

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

    r678 r679  
    4343char *oath_key_to_uri(const struct oath_key *);
    4444
    45 #define DUMMY_LABEL     ("oath-dummy-key")
    46 #define DUMMY_LABELLEN  (sizeof DUMMY_LABEL)
    47 #define DUMMY_KEYLEN    64
    48 
    4945struct oath_key *oath_dummy_key(enum oath_mode, enum oath_hash, unsigned int);
    5046
  • trunk/include/security/oath_constants.h

    r678 r679  
    7777#define OATH_MAX_LABELLEN       64
    7878
     79/*
     80 * Label to use for dummy keys
     81 */
     82#define OATH_DUMMY_LABEL        "oath-dummy-key"
     83
    7984#endif
  • trunk/lib/liboath/oath_hotp.c

    r646 r679  
    128128        if (k->counter >= UINT64_MAX - window)
    129129                return (-1);
    130         dummy = (memcmp(k->label, DUMMY_LABEL, DUMMY_LABELLEN) == 0);
     130        dummy = (strcmp(k->label, OATH_DUMMY_LABEL) == 0);
    131131        for (int i = 0; i < window; ++i) {
    132132                code = oath_hotp(k->key, k->keylen, k->counter + i, k->digits);
  • trunk/lib/liboath/oath_key.c

    r678 r679  
    311311        key->timestep = 30;
    312312        key->hash = hash;
    313         memcpy(key->label, DUMMY_LABEL, DUMMY_LABELLEN);
    314         key->labellen = DUMMY_LABELLEN;
    315         key->keylen = DUMMY_KEYLEN;
     313        strcpy(key->label, "oath-dummy-key");
     314        key->labellen = strlen(key->label);
     315        key->keylen = sizeof key->key;
    316316        return (key);
    317317}
  • trunk/lib/liboath/oath_totp.c

    r646 r679  
    8484                return (-1);
    8585        seq = time(NULL) / k->timestep;
    86         dummy = (memcmp(k->label, DUMMY_LABEL, DUMMY_LABELLEN) == 0);
     86        dummy = (strcmp(k->label, OATH_DUMMY_LABEL) == 0);
    8787        for (int i = -window; i <= window; ++i) {
    8888                code = oath_hotp(k->key, k->keylen, seq + i, k->digits);
Note: See TracChangeset for help on using the changeset viewer.