mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Apply style guide rules to certificate, key and reachability classes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user