Apply style guide rules to certificate, key and reachability classes

This commit is contained in:
Sergey Abramchuk
2018-01-18 17:00:28 +03:00
parent eff0bccfef
commit 7078de3bae
9 changed files with 63 additions and 59 deletions
+20 -20
View File
@@ -8,8 +8,9 @@
#import "OpenVPNPrivateKey.h"
#import <mbedtls/pk.h>
#include <mbedtls/pk.h>
#import "OpenVPNKeyType.h"
#import "NSError+OpenVPNError.h"
@interface OpenVPNPrivateKey ()
@@ -20,23 +21,6 @@
@implementation OpenVPNPrivateKey
- (instancetype)init {
self = [super init];
if (self) {
self.ctx = malloc(sizeof(mbedtls_pk_context));
mbedtls_pk_init(self.ctx);
}
return self;
}
- (NSInteger)size {
return mbedtls_pk_get_bitlen(self.ctx);
}
- (OpenVPNKeyType)type {
return (OpenVPNKeyType)mbedtls_pk_get_type(self.ctx);
}
+ (nullable OpenVPNPrivateKey *)keyWithPEM:(NSData *)pemData password:(NSString *)password error:(out NSError **)error {
OpenVPNPrivateKey *key = [OpenVPNPrivateKey new];
@@ -78,6 +62,22 @@
return key;
}
- (instancetype)init {
if (self = [super init]) {
_ctx = malloc(sizeof(mbedtls_pk_context));
mbedtls_pk_init(_ctx);
}
return self;
}
- (NSInteger)size {
return mbedtls_pk_get_bitlen(self.ctx);
}
- (OpenVPNKeyType)type {
return (OpenVPNKeyType)mbedtls_pk_get_type(self.ctx);
}
- (NSData *)pemData:(out NSError **)error {
size_t buffer_length = mbedtls_pk_get_len(self.ctx) * 10;
unsigned char *pem_buffer = malloc(buffer_length);
@@ -123,8 +123,8 @@
}
- (void)dealloc {
mbedtls_pk_free(self.ctx);
free(self.ctx);
mbedtls_pk_free(_ctx);
free(_ctx);
}
@end