Changeset 655 in openpam for trunk/include/security/oath_types.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 copied

Legend:

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

    r654 r655  
    3030 */
    3131
    32 #ifndef OATH_H_INCLUDED
    33 #define OATH_H_INCLUDED
     32#ifndef OATH_TYPES_H_INCLUDED
     33#define OATH_TYPES_H_INCLUDED
    3434
    3535/*
    36  * Default time step for TOTP: 30 seconds.
     36 * OATH key and associated parameters
    3737 */
    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 */
    7538struct oath_key {
    7639        /* mode and parameters */
     
    9659};
    9760
    98 struct oath_key *oath_key_alloc(size_t);
    99 void oath_key_free(struct oath_key *);
    100 struct oath_key *oath_key_from_uri(const char *);
    101 struct oath_key *oath_key_from_file(const char *);
    102 char *oath_key_to_uri(const struct oath_key *);
    103 
    104 #define DUMMY_LABEL     ("oath-dummy-key")
    105 #define DUMMY_LABELLEN  (sizeof DUMMY_LABEL)
    106 #define DUMMY_KEYLEN    80
    107 
    108 struct oath_key *oath_dummy_key(enum oath_mode, enum oath_hash, unsigned int);
    109 
    110 unsigned int oath_hotp(const uint8_t *, size_t, uint64_t, unsigned int);
    111 int oath_hotp_current(struct oath_key *);
    112 int oath_hotp_match(struct oath_key *, unsigned int, int);
    113 
    114 unsigned int oath_totp(const uint8_t *, size_t, unsigned int);
    115 int oath_totp_match(const struct oath_key *, unsigned int, int);
    116 unsigned int oath_totp_current(const struct oath_key *);
    117 
    11861#endif
Note: See TracChangeset for help on using the changeset viewer.