Inherits from NSObject
Declared in AGOtp.h
AGOtp.m

Overview

The Otp class generates a one-time password (OTP) using the HMAC-Based One-Time Password Algorithm described in RFC6238: http://tools.ietf.org/html/rfc6238

The HOTP algorithm is based on an increasing counter value and a static symmetric key known only to the token and the validation service. In order to create the HOTP value, we will use the HMAC- SHA-1 algorithm, as defined in RFC 2104.

As the output of the HMAC-SHA-1 calculation is 160 bits, we must truncate this value to something that can be easily entered by a user.

HOTP(K,C) = Truncate(HMAC-SHA-1(K,C))

Where:

  • Truncate represents the function that converts an HMAC-SHA-1 value into an HOTP value as defined in Section 5.3 of RFC4226.

The Key (K), the Counter ©, and Data values are hashed high-order byte first.

The HOTP values generated by the HOTP generator are treated as big endian.

Tasks

Instance Methods

generateOTP

Entry point to generate an OTP token.

- (NSString *)generateOTP

Return Value

An NSString that contains the token with leading zero-padding as required.

Discussion

Entry point to generate an OTP token.

NOTE: Subclasses should override this method.

Declared In

AGOtp.h

generateOTPForCounter:

Generate an OTP token using the specified counter.

- (NSString *)generateOTPForCounter:(uint64_t)counter

Parameters

counter

The counter to use.

Return Value

An NSString that contains the token with leading zero-padding as required.

Discussion

Generate an OTP token using the specified counter.

Declared In

AGOtp.h

initWithSecret:

Returns an AGOtp object initialized with a secret specified by the given string.

- (id)initWithSecret:(NSData *)secret

Parameters

secret

The secret to use.

Return Value

An AGTotp object initialized by the specified secret.

Discussion

Returns an AGOtp object initialized with a secret specified by the given string.

Declared In

AGOtp.h