Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Adding missing MessageKeys serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericJacobs committed Dec 31, 2014
1 parent c891280 commit 8347c85
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AxolotlKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AxolotlKit"
s.version = "0.4"
s.version = "0.5"
s.summary = "AxolotlKit is a Free implementation of the Axolotl protocol in Objective-C"
s.homepage = "https://github.com/WhisperSystems/AxolotlKit"
s.license = "GPLv2"
Expand Down
2 changes: 1 addition & 1 deletion AxolotlKit/Classes/Ratchet/MessageKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>

@interface MessageKeys : NSObject
@interface MessageKeys : NSObject <NSSecureCoding>

- (instancetype)initWithCipherKey:(NSData*)cipherKey macKey:(NSData*)macKey iv:(NSData*)data index:(int)index;

Expand Down
26 changes: 26 additions & 0 deletions AxolotlKit/Classes/Ratchet/MessageKeys.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,34 @@

#import "MessageKeys.h"

static NSString* const kCoderMessageKeysCipherKey = @"kCoderMessageKeysCipherKey";
static NSString* const kCoderMessageKeysMacKey = @"kCoderMessageKeysMacKey";
static NSString* const kCoderMessageKeysIVKey = @"kCoderMessageKeysIVKey";
static NSString* const kCoderMessageKeysIndex = @"kCoderMessageKeysIndex";


@implementation MessageKeys

+ (BOOL)supportsSecureCoding{
return YES;
}

- (id)initWithCoder:(NSCoder *)aDecoder{
self = [self initWithCipherKey:[aDecoder decodeObjectOfClass:[NSData class] forKey:kCoderMessageKeysCipherKey]
macKey:[aDecoder decodeObjectOfClass:[NSData class] forKey:kCoderMessageKeysMacKey]
iv:[aDecoder decodeObjectOfClass:[NSData class] forKey:kCoderMessageKeysIVKey]
index:[aDecoder decodeIntForKey:kCoderMessageKeysIndex]];
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
[aCoder encodeObject:self.cipherKey forKey:kCoderMessageKeysCipherKey];
[aCoder encodeObject:self.macKey forKey:kCoderMessageKeysMacKey];
[aCoder encodeObject:self.iv forKey:kCoderMessageKeysIVKey];
[aCoder encodeInt:self.index forKey:kCoderMessageKeysIndex];
}


- (instancetype)initWithCipherKey:(NSData*)cipherKey macKey:(NSData*)macKey iv:(NSData *)data index:(int)index{
self = [super init];

Expand Down

0 comments on commit 8347c85

Please sign in to comment.