зеркало из https://github.com/github/SoftU2F.git
run clang-format
This commit is contained in:
Родитель
007eee7e98
Коммит
3aec00cfea
|
@ -0,0 +1,3 @@
|
|||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 0
|
||||
BreakBeforeBraces: Attach
|
2
SoftU2F
2
SoftU2F
|
@ -1 +1 @@
|
|||
Subproject commit ba2682d64b5b9a6fbb163f743d9ddcb3c1f18925
|
||||
Subproject commit ff64767d1a559183695e64e1fa2c3e340a44e27c
|
|
@ -8,15 +8,16 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
#undef I // complex.h defines some crazy `I` macro...
|
||||
#import <openssl/x509.h>
|
||||
#import <openssl/asn1.h>
|
||||
#import <openssl/ec.h>
|
||||
#import <openssl/ecdsa.h>
|
||||
#import <openssl/evp.h>
|
||||
#import <openssl/objects.h>
|
||||
#import <openssl/asn1.h>
|
||||
#import <openssl/pem.h>
|
||||
#import <openssl/x509.h>
|
||||
|
||||
@interface SelfSignedCertificate : NSObject
|
||||
|
||||
@interface SelfSignedCertificate : NSObject;
|
||||
@property EVP_PKEY *pkey;
|
||||
@property X509 *x509;
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
@implementation SelfSignedCertificate
|
||||
|
||||
- (id)init
|
||||
{
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if ([self generateKeyPair] && [self generateX509]) {
|
||||
|
@ -25,8 +24,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (int)generateX509
|
||||
{
|
||||
- (int)generateX509 {
|
||||
self.x509 = X509_new();
|
||||
if (self.x509 == NULL) {
|
||||
printf("failed to init x509\n");
|
||||
|
@ -56,8 +54,7 @@
|
|||
return 1;
|
||||
}
|
||||
|
||||
- (int)generateKeyPair
|
||||
{
|
||||
- (int)generateKeyPair {
|
||||
self.pkey = EVP_PKEY_new();
|
||||
if (self.pkey == NULL) {
|
||||
printf("failed to init pkey\n");
|
||||
|
@ -98,15 +95,13 @@
|
|||
return 1;
|
||||
}
|
||||
|
||||
- (NSData*)toDer
|
||||
{
|
||||
- (NSData *)toDer {
|
||||
unsigned char *buf = NULL;
|
||||
unsigned int len = i2d_X509(self.x509, &buf);
|
||||
return [[NSData alloc] initWithBytes:buf length:len];
|
||||
}
|
||||
|
||||
- (NSData*)signData:(NSData*)msg
|
||||
{
|
||||
- (NSData *)signData:(NSData *)msg {
|
||||
EVP_MD_CTX ctx;
|
||||
const unsigned char *cmsg = (const unsigned char *)[msg bytes];
|
||||
unsigned char *sig = (unsigned char *)malloc(EVP_PKEY_size(self.pkey));
|
||||
|
@ -133,10 +128,11 @@
|
|||
return [[NSData alloc] initWithBytes:sig length:len];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
X509_free(self.x509); self.x509 = NULL;
|
||||
EVP_PKEY_free(self.pkey); self.pkey = NULL;
|
||||
- (void)dealloc {
|
||||
X509_free(self.x509);
|
||||
self.x509 = NULL;
|
||||
EVP_PKEY_free(self.pkey);
|
||||
self.pkey = NULL;
|
||||
}
|
||||
|
||||
+ (bool)parseX509:(NSData *)data consumed:(NSInteger *)consumed;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#import <CommonCrypto/CommonCrypto.h>
|
||||
#import <Security/Security.h>
|
||||
#import <Security/SecKey.h>
|
||||
#import "SelfSignedCertificate.h"
|
||||
#import "softu2f.h"
|
||||
#import "u2f.h"
|
||||
#import "u2f_hid.h"
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
#import <Security/SecKey.h>
|
||||
#import <Security/Security.h>
|
||||
|
|
Загрузка…
Ссылка в новой задаче