session-ios/SignalServiceKit/src/Network/API/Requests/TSRegisterSignedPrekeyRequest.m
Michael Kirk ccb4a88742 Import SSK (and history) into Signal-iOS
git remote add ssk ../SignalServiceKit
git remote update
git merge -s ours --allow-unrelated-histories --no-commit ssk/master
git read-tree --prefix=SignalServiceKit -u ssk/master
git commit
2017-07-21 13:55:01 -04:00

37 lines
1 KiB
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSRegisterSignedPrekeyRequest.h"
#import "TSConstants.h"
#import <25519/Curve25519.h>
#import <AxolotlKit/NSData+keyVersionByte.h>
#import <AxolotlKit/PreKeyRecord.h>
#import <AxolotlKit/SignedPreKeyStore.h>
@implementation TSRegisterSignedPrekeyRequest
- (id)initWithSignedPreKeyRecord:(SignedPreKeyRecord *)signedRecord
{
self = [super initWithURL:[NSURL URLWithString:textSecureSignedKeysAPI]];
self.HTTPMethod = @"PUT";
NSDictionary *serializedKeyRegistrationParameters = [self dictionaryFromSignedPreKey:signedRecord];
self.parameters = [serializedKeyRegistrationParameters mutableCopy];
return self;
}
- (NSDictionary *)dictionaryFromSignedPreKey:(SignedPreKeyRecord *)preKey
{
return @{
@"keyId" : [NSNumber numberWithInt:preKey.Id],
@"publicKey" : [[preKey.keyPair.publicKey prependKeyType] base64EncodedStringWithOptions:0],
@"signature" : [preKey.signature base64EncodedStringWithOptions:0]
};
}
@end