Merge branch 'jrose/remove-AxolotlKit' into feature/SignalClient-adoption
This commit is contained in:
commit
af0c4d1753
@ -39,15 +39,12 @@ A Swift & Objective-C library used by other Signal libraries.
|
||||
|
||||
s.resources = ["SignalMetadataKit/Resources/Certificates/*"]
|
||||
|
||||
s.dependency 'AxolotlKit'
|
||||
s.dependency 'CocoaLumberjack'
|
||||
s.dependency 'Curve25519Kit'
|
||||
s.dependency 'HKDFKit'
|
||||
s.dependency 'SignalClient'
|
||||
s.dependency 'SignalCoreKit'
|
||||
s.dependency 'SwiftProtobuf'
|
||||
|
||||
s.dependency 'SignalClient'
|
||||
|
||||
s.test_spec 'Tests' do |test_spec|
|
||||
test_spec.source_files = 'SignalMetadataKitTests/src/**/*.{h,m,swift}'
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -11,10 +11,7 @@ public enum SMKCertificateError: Error {
|
||||
case invalidCertificate(description: String)
|
||||
}
|
||||
|
||||
@objc(SMKCertificateValidator)
|
||||
public protocol SMKCertificateValidatorObjC {}
|
||||
|
||||
public protocol SMKCertificateValidator: SMKCertificateValidatorObjC {
|
||||
public protocol SMKCertificateValidator {
|
||||
func throwswrapped_validate(senderCertificate: SenderCertificate, validationTime: UInt64) throws
|
||||
func throwswrapped_validate(serverCertificate: ServerCertificate) throws
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AxolotlKit
|
||||
import Curve25519Kit
|
||||
import SignalCoreKit
|
||||
import SignalClient
|
||||
|
||||
@objc
|
||||
@ -164,16 +164,16 @@ fileprivate extension SMKMessageType {
|
||||
|
||||
private let kSMKSecretSessionCipherMacLength: UInt = 10
|
||||
|
||||
private let sessionStore: SignalClient.SessionStore
|
||||
private let preKeyStore: SignalClient.PreKeyStore
|
||||
private let signedPreKeyStore: SignalClient.SignedPreKeyStore
|
||||
private let identityStore: SignalClient.IdentityKeyStore
|
||||
private let sessionStore: SessionStore
|
||||
private let preKeyStore: PreKeyStore
|
||||
private let signedPreKeyStore: SignedPreKeyStore
|
||||
private let identityStore: IdentityKeyStore
|
||||
|
||||
// public SecretSessionCipher(SignalProtocolStore signalProtocolStore) {
|
||||
public init(sessionStore: SignalClient.SessionStore,
|
||||
preKeyStore: SignalClient.PreKeyStore,
|
||||
signedPreKeyStore: SignalClient.SignedPreKeyStore,
|
||||
identityStore: SignalClient.IdentityKeyStore) throws {
|
||||
public init(sessionStore: SessionStore,
|
||||
preKeyStore: PreKeyStore,
|
||||
signedPreKeyStore: SignedPreKeyStore,
|
||||
identityStore: IdentityKeyStore) throws {
|
||||
|
||||
self.sessionStore = sessionStore
|
||||
self.preKeyStore = preKeyStore
|
||||
@ -181,18 +181,6 @@ fileprivate extension SMKMessageType {
|
||||
self.identityStore = identityStore
|
||||
}
|
||||
|
||||
@objc(initWithSessionStore:preKeyStore:signedPreKeyStore:identityStore:error:)
|
||||
public convenience init(transitionalSessionStore sessionStore: AxolotlKit.SessionStore,
|
||||
preKeyStore: AxolotlKit.PreKeyStore,
|
||||
signedPreKeyStore: AxolotlKit.SignedPreKeyStore,
|
||||
identityStore: AxolotlKit.IdentityKeyStore) throws {
|
||||
try self.init(
|
||||
sessionStore: sessionStore as! SignalClient.SessionStore,
|
||||
preKeyStore: preKeyStore as! SignalClient.PreKeyStore,
|
||||
signedPreKeyStore: signedPreKeyStore as! SignalClient.SignedPreKeyStore,
|
||||
identityStore: identityStore as! SignalClient.IdentityKeyStore)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
// public byte[] encrypt(SignalProtocolAddress destinationAddress, SenderCertificate senderCertificate, byte[] paddedPlaintext)
|
||||
@ -200,7 +188,7 @@ fileprivate extension SMKMessageType {
|
||||
deviceId: Int32,
|
||||
paddedPlaintext: Data,
|
||||
senderCertificate: SenderCertificate,
|
||||
protocolContext: SPKProtocolWriteContext?) throws -> Data {
|
||||
protocolContext: StoreContext?) throws -> Data {
|
||||
guard deviceId > 0 else {
|
||||
throw SMKError.assertionError(description: "\(logTag) invalid deviceId")
|
||||
}
|
||||
@ -213,25 +201,24 @@ fileprivate extension SMKMessageType {
|
||||
from: senderCertificate,
|
||||
sessionStore: sessionStore,
|
||||
identityStore: identityStore,
|
||||
context: (protocolContext as! StoreContext?) ?? NullContext()))
|
||||
context: protocolContext ?? NullContext()))
|
||||
}
|
||||
|
||||
// public Pair<SignalProtocolAddress, byte[]> decrypt(CertificateValidator validator, byte[] ciphertext, long timestamp)
|
||||
// throws InvalidMetadataMessageException, InvalidMetadataVersionException, ProtocolInvalidMessageException, ProtocolInvalidKeyException, ProtocolNoSessionException, ProtocolLegacyMessageException, ProtocolInvalidVersionException, ProtocolDuplicateMessageException, ProtocolInvalidKeyIdException, ProtocolUntrustedIdentityException
|
||||
@objc
|
||||
public func throwswrapped_decryptMessage(certificateValidator: SMKCertificateValidatorObjC,
|
||||
public func throwswrapped_decryptMessage(certificateValidator: SMKCertificateValidator,
|
||||
cipherTextData: Data,
|
||||
timestamp: UInt64,
|
||||
localE164: String?,
|
||||
localUuid: UUID?,
|
||||
localDeviceId: Int32,
|
||||
protocolContext: SPKProtocolWriteContext?) throws -> SMKDecryptResult {
|
||||
protocolContext: StoreContext?) throws -> SMKDecryptResult {
|
||||
guard timestamp > 0 else {
|
||||
throw SMKError.assertionError(description: "\(logTag) invalid timestamp")
|
||||
}
|
||||
|
||||
// Allow nil contexts for testing.
|
||||
let context = (protocolContext as! StoreContext?) ?? NullContext()
|
||||
let context = protocolContext ?? NullContext()
|
||||
let messageContent = try UnidentifiedSenderMessageContent(message: cipherTextData,
|
||||
identityStore: self.identityStore,
|
||||
context: context)
|
||||
@ -247,7 +234,6 @@ fileprivate extension SMKMessageType {
|
||||
|
||||
do {
|
||||
// validator.validate(content.getSenderCertificate(), timestamp);
|
||||
let certificateValidator = certificateValidator as! SMKCertificateValidator
|
||||
try certificateValidator.throwswrapped_validate(
|
||||
senderCertificate: messageContent.senderCertificate,
|
||||
validationTime: timestamp)
|
||||
|
||||
@ -100,14 +100,14 @@ class MockClient: NSObject {
|
||||
let bobSignedPreKey = bobMockClient.generateMockSignedPreKey()
|
||||
|
||||
// PreKeyBundle bobBundle = new PreKeyBundle(1, 1, 1, bobPreKey.getPublicKey(), 2, bobSignedPreKey.getKeyPair().getPublicKey(), bobSignedPreKey.getSignature(), bobIdentityKey.getPublicKey());
|
||||
let bobBundle = try! SignalClient.PreKeyBundle(registrationId: UInt32(bitPattern: bobMockClient.registrationId),
|
||||
deviceId: UInt32(bitPattern: bobMockClient.deviceId),
|
||||
prekeyId: bobPreKey.id,
|
||||
prekey: bobPreKey.publicKey,
|
||||
signedPrekeyId: bobSignedPreKey.id,
|
||||
signedPrekey: bobSignedPreKey.publicKey,
|
||||
signedPrekeySignature: bobSignedPreKey.signature,
|
||||
identity: bobIdentityKey.identityKey)
|
||||
let bobBundle = try! PreKeyBundle(registrationId: UInt32(bitPattern: bobMockClient.registrationId),
|
||||
deviceId: UInt32(bitPattern: bobMockClient.deviceId),
|
||||
prekeyId: bobPreKey.id,
|
||||
prekey: bobPreKey.publicKey,
|
||||
signedPrekeyId: bobSignedPreKey.id,
|
||||
signedPrekey: bobSignedPreKey.publicKey,
|
||||
signedPrekeySignature: bobSignedPreKey.signature,
|
||||
identity: bobIdentityKey.identityKey)
|
||||
|
||||
// SessionBuilder aliceSessionBuilder = new SessionBuilder(aliceStore, new SignalProtocolAddress("+14152222222", 1));
|
||||
// aliceSessionBuilder.process(bobBundle);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user