FRAOathMechanism.m revision e2d1c3c0c150e511b0df83a3c49451ae773ea93a
/*
* 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
*/
#import "FRAOathMechanism.h"
#import "base32.h"
#import <CommonCrypto/CommonHMAC.h>
#import <sys/time.h>
if (c >= '0' && c <= '9') {
return YES;
}
if (c >= 'A' && c <= 'F') {
return YES;
}
if (c >= 'a' && c <= 'f') {
return YES;
}
return NO;
}
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
}
return 0;
}
return nil;
}
continue;
}
uint8_t c = 0;
}
return ret;
}
return nil;
}
return nil;
}
return nil;
}
}
static struct {
const char *name;
} algomap[] = {
{ "md5", kCCHmacAlgMD5 },
{ "sha1", kCCHmacAlgSHA1 },
{ "sha256", kCCHmacAlgSHA256 },
{ "sha512", kCCHmacAlgSHA512 },
};
return kCCHmacAlgSHA1;
}
return kCCHmacAlgSHA1;
}
}
}
return kCCHmacAlgSHA1;
}
return 6;
}
return 6;
}
return val;
}
switch (algo) {
case kCCHmacAlgMD5:
return CC_MD5_DIGEST_LENGTH;
case kCCHmacAlgSHA256:
return CC_SHA256_DIGEST_LENGTH;
case kCCHmacAlgSHA512:
return CC_SHA512_DIGEST_LENGTH;
case kCCHmacAlgSHA1:
default:
return CC_SHA1_DIGEST_LENGTH;
}
}
// Network byte order
// Create digits divisor
for (int i = digits; i > 0; i--) {
div *= 10;
}
// Create the HMAC
// Truncate
}
}
return nil;
}
return nil;
}
return nil;
}
// Get the path and strip it of its leading '/'
return nil;
}
}
return nil;
}
// Get issuer and label
return nil;
}
} else {
_issuer = @"";
}
// Parse query
// Value can contain '=' symbols, so look for first symbol.
continue;
}
}
// Get key
return nil;
}
// Get algorithm and digits
// Get period
if (period == 0) {
period = 30;
}
// Get counter
}
// Get image
NSURL* _image = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"forgerock-logo" ofType:@"png"]];
// Set owner
// Set uid
_uid = -1;
return self;
}
}
- (FRAOathCode*)code {
now = 0;
}
}
}
@end