mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Add boilerplate for OpenVPNPrivateKey implementation
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// OpenVPNPrivateKey.h
|
||||||
|
// OpenVPN Adapter
|
||||||
|
//
|
||||||
|
// Created by Sergey Abramchuk on 07.09.17.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface OpenVPNPrivateKey : NSObject
|
||||||
|
|
||||||
|
+ (nullable OpenVPNPrivateKey *)keyWithPEM:(nonnull NSData *)pemData
|
||||||
|
password:(nullable NSString *)password
|
||||||
|
error:(out NSError * __nullable * __nullable)error;
|
||||||
|
|
||||||
|
+ (nullable OpenVPNPrivateKey *)keyWithDER:(nonnull NSData *)derData
|
||||||
|
password:(nullable NSString *)password
|
||||||
|
error:(out NSError * __nullable * __nullable)error;
|
||||||
|
|
||||||
|
- (nonnull instancetype) __unavailable init;
|
||||||
|
|
||||||
|
- (nullable NSData *)pemData:(out NSError * __nullable * __nullable)error;
|
||||||
|
- (nullable NSData *)derData:(out NSError * __nullable * __nullable)error;
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// OpenVPNPrivateKey.m
|
||||||
|
// OpenVPN Adapter
|
||||||
|
//
|
||||||
|
// Created by Sergey Abramchuk on 07.09.17.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <mbedtls/pk.h>
|
||||||
|
|
||||||
|
#import "NSError+Message.h"
|
||||||
|
#import "OpenVPNError.h"
|
||||||
|
#import "OpenVPNPrivateKey.h"
|
||||||
|
|
||||||
|
@interface OpenVPNPrivateKey ()
|
||||||
|
|
||||||
|
@property (nonatomic, assign) mbedtls_pk_context *key;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation OpenVPNPrivateKey
|
||||||
|
|
||||||
|
- (instancetype)init {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
self.key = malloc(sizeof(mbedtls_pk_context));
|
||||||
|
mbedtls_pk_init(self.key);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (nullable OpenVPNPrivateKey *)keyWithPEM:(NSData *)pemData password:(NSString *)password error:(out NSError **)error {
|
||||||
|
OpenVPNPrivateKey *key = [OpenVPNPrivateKey new];
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (nullable OpenVPNPrivateKey *)keyWithDER:(NSData *)derData password:(NSString *)password error:(out NSError **)error {
|
||||||
|
OpenVPNPrivateKey *key = [OpenVPNPrivateKey new];
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
mbedtls_pk_free(self.key);
|
||||||
|
free(self.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
Reference in New Issue
Block a user