From 6c993be9f1b0c2162716d47eda113129ade53d63 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Sat, 23 Dec 2017 04:31:43 -0500 Subject: [PATCH] (feat) add KEY support for certificate handling --- SOPE/NGCards/NGVCard.h | 2 ++ SOPE/NGCards/NGVCard.m | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/SOPE/NGCards/NGVCard.h b/SOPE/NGCards/NGVCard.h index 9553da380..f070e7153 100644 --- a/SOPE/NGCards/NGVCard.h +++ b/SOPE/NGCards/NGVCard.h @@ -128,6 +128,8 @@ typedef enum - (NSArray *) categories; - (NSString *) photo; - (void) setPhoto: (NSString *) _value; +- (NSData *) certificate; +- (void) setCertificate: (NSData *) theCertificate; // - (void) setN: (NGVCardName *) _v; diff --git a/SOPE/NGCards/NGVCard.m b/SOPE/NGCards/NGVCard.m index 24f1f879e..48cc9d9a7 100644 --- a/SOPE/NGCards/NGVCard.m +++ b/SOPE/NGCards/NGVCard.m @@ -302,6 +302,27 @@ [photo setSingleValue: _value forKey: @""]; } +- (NSData *) certificate +{ + CardElement *key; + + key = [self uniqueChildWithTag: @"key"]; + return [[[key valuesAtIndex: 0 forKey: @""] objectAtIndex: 0] dataByDecodingBase64]; +} + +- (void) setCertificate: (NSData *) theCertificate +{ + CardElement *key; + NSString *value; + + value = [theCertificate stringByEncodingBase64]; + key = [self uniqueChildWithTag: @"key"]; + [key setValue: 0 ofAttribute: @"encoding" to: @"base64"]; + [key setValue: 0 ofAttribute: @"type" to: @"application/pkcs7-signature"]; + + [key setSingleValue: value forKey: @""]; +} + - (void) setOrg: (NSString *) anOrg units: (NSArray *) someUnits