FRAOathMechanism.h revision 91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5b
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*
* Portions Copyright 2014 Nathaniel McCallum, Red Hat
*/
@class FRAIdentity;
@class FRAOathCode;
#import "FRAMechanism.h"
#include <CommonCrypto/CommonHMAC.h>
/*!
* An OATH authentication mechanism capable of generating HMAC- and Time-based One-Time Passwords.
*/
@interface FRAOathMechanism : FRAMechanism
/*!
* The version number of this OATH mechanism.
*/
@property (nonatomic, readonly) NSInteger version;
/*!
* The type of this OATH mechanism (totp or hotp).
*/
@property (nonatomic, readonly) NSString* type;
/*!
* The length of the OATH code generated by this mechanism. Always 6 or 8; defaults to 6.
*/
@property (nonatomic, readonly) NSUInteger digits;
/*!
* The current login code for this OATH mechanism.
*/
@property (nonatomic, readonly) FRAOathCode* code;
/*!
* Initialise an OATH Mechanism with all required field to describe either
* a HOTP or a TOTP mechanism.
* @param Type either "hotp" or "totp".
* @param Secret key bytes used to generate HMAC.
* @param The HMAC algorithm to use. Currently only MD5, SHA256, SHA512 and SHA1 are supported.
* @param The length of the key.
* @param TOTP based refresh period.
* @param HOTP hash counter.
*/
- (instancetype) initWithType:(NSString*)type usingSecretKey:(NSData*)secretKey andHMACAlgorithm:(CCHmacAlgorithm)algorithm withKeyLength:(NSUInteger)digits andEitherPeriod:(NSUInteger)period orCounter:(NSUInteger)counter;
/*!
* Generates the next code for this OATH mechanism.
*/
- (void)generateNextCode;
@end