Changeset 655 in openpam for trunk/include/security/oath.h


Ignore:
Timestamp:
Mar 6, 2013, 2:10:09 PM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

Split up the liboath header files.

File:
1 edited

Legend:

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

    r646 r655  
    3333#define OATH_H_INCLUDED
    3434
    35 /*
    36  * Default time step for TOTP: 30 seconds.
    37  */
    38 #define OATH_DEF_TIMESTEP       30
    39 
    40 /*
    41  * Maximum time step for TOTP: 10 minutes, which RFC 6238 cites as an
    42  * example of an unreasonably large time step.
    43  */
    44 #define OATH_MAX_TIMESTEP       600
    45 
    46 /*
    47  * Maximum key length in bytes.  HMAC has a 64-byte block size; if the key
    48  * K is longer than that, HMAC derives a new key K' = H(K).
    49  */
    50 #define OATH_MAX_KEYLEN         64
    51 
    52 /* estimate of output length for base32 encoding / decoding */
    53 #define base32_enclen(l) (size_t)(((l + 4) / 5) * 8)
    54 #define base32_declen(l) (size_t)(((l + 7) / 8) * 5)
    55 
    56 /* base32 encoding / decoding */
    57 int base32_enc(const uint8_t *, size_t, char *, size_t *);
    58 int base32_dec(const char *, size_t, uint8_t *, size_t *);
    59 
    60 /* estimate of output length for base64 encoding / decoding */
    61 #define base64_enclen(l) (size_t)(((l + 2) / 3) * 4)
    62 #define base64_declen(l) (size_t)(((l + 3) / 4) * 3)
    63 
    64 /* base64 encoding / decoding */
    65 int base64_enc(const uint8_t *, size_t, char *, size_t *);
    66 int base64_dec(const char *, size_t, uint8_t *, size_t *);
    67 
    68 /* mode: hotp (event mode) or totp (time-synch mode) */
    69 enum oath_mode { om_undef, om_hotp, om_totp };
    70 
    71 /* hash function */
    72 enum oath_hash { oh_undef, oh_sha1, oh_sha256, oh_sha512, oh_md5 };
    73 
    74 /* key structure */
    75 struct oath_key {
    76         /* mode and parameters */
    77         enum oath_mode   mode;
    78         unsigned int     digits;
    79         uint64_t         counter;
    80         unsigned int     timestep; /* in seconds */
    81 
    82         /* hash algorithm */
    83         enum oath_hash   hash;
    84 
    85         /* label */
    86         size_t           labellen; /* bytes incl. NUL */
    87         char            *label;
    88 
    89         /* key */
    90         size_t           keylen; /* bytes */
    91         uint8_t         *key;
    92 
    93         /* buffer for label + NUL + key */
    94         size_t           datalen; /* bytes */
    95         uint8_t          data[];
    96 };
     35#include <security/oath_constants.h>
     36#include <security/oath_types.h>
     37#include <security/oath_rfc4648.h>
    9738
    9839struct oath_key *oath_key_alloc(size_t);
Note: See TracChangeset for help on using the changeset viewer.