Changeset 689 in openpam for trunk/lib/liboath/oath_key.c


Ignore:
Timestamp:
Jul 12, 2013, 10:47:14 AM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

Factor out oath_key_{alloc,free}() and implement wiring / locking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/liboath/oath_key.c

    r679 r689  
    3939#include <inttypes.h>
    4040#include <limits.h>
    41 #include <stdint.h>
    4241#include <stdio.h>
    4342#include <stdlib.h>
     
    5150
    5251#include <security/oath.h>
    53 
    54 /*
    55  * Allocate a struct oath_key with sufficient additional space for the
    56  * label and key.
    57  */
    58 struct oath_key *
    59 oath_key_alloc(void)
    60 {
    61         struct oath_key *key;
    62 
    63         if ((key = calloc(1, sizeof *key)) == NULL) {
    64                 openpam_log(PAM_LOG_ERROR, "malloc(): %s", strerror(errno));
    65                 return (NULL);
    66         }
    67         /* XXX should try to wire */
    68         return (key);
    69 }
    70 
    71 /*
    72  * Wipe and free a struct oath_key
    73  */
    74 void
    75 oath_key_free(struct oath_key *key)
    76 {
    77 
    78         if (key != NULL) {
    79                 memset(key, 0, sizeof *key);
    80                 free(key);
    81         }
    82 }
    8352
    8453/*
Note: See TracChangeset for help on using the changeset viewer.