Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
Remove some unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
max-signal authored Sep 25, 2023
1 parent 8c92ef2 commit da1f1fd
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 195 deletions.
2 changes: 0 additions & 2 deletions SignalCoreKit/src/Cryptography.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ typedef NS_ENUM(NSInteger, TSMACType) {

+ (NSData *)generateRandomBytes:(NSUInteger)numberBytes;

+ (uint32_t)randomUInt32;
+ (uint64_t)randomUInt64;
+ (unsigned)randomUnsigned;

#pragma mark -

Expand Down
9 changes: 0 additions & 9 deletions SignalCoreKit/src/Cryptography.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ + (NSData *)generateRandomBytes:(NSUInteger)numberBytes
return [Randomness generateRandomBytes:(int)numberBytes];
}

+ (uint32_t)randomUInt32
{
size_t size = sizeof(uint32_t);
NSData *data = [self generateRandomBytes:size];
uint32_t result = 0;
[data getBytes:&result range:NSMakeRange(0, size)];
return result;
}

+ (uint64_t)randomUInt64
{
size_t size = sizeof(uint64_t);
Expand Down
46 changes: 0 additions & 46 deletions SignalCoreKit/src/Cryptography.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,6 @@ import Foundation
import CommonCrypto

public extension Cryptography {
class func pbkdf2Derivation(password: Data, salt: Data, iterations: UInt32, outputLength: Int) -> Data? {
guard password.count > 0 else {
owsFailDebug("Invalid password.")
return nil
}

guard salt.count > 0 else {
owsFailDebug("Invalid salt.")
return nil
}

guard iterations > 0 else {
owsFailDebug("Invalid iterations.")
return nil
}

guard outputLength > 0 else {
owsFailDebug("Invalid outputLength.")
return nil
}

let passwordBytes: [Int8] = password.withUnsafeBytes {
[Int8]($0.bindMemory(to: Int8.self))
}
let saltBytes: [UInt8] = salt.withUnsafeBytes { [UInt8]($0) }
var outputBytes = [UInt8](repeating: 0, count: outputLength)
let status = CCKeyDerivationPBKDF(
CCPBKDFAlgorithm(kCCPBKDF2),
passwordBytes,
passwordBytes.count,
saltBytes,
saltBytes.count,
CCPBKDFAlgorithm(kCCPRFHmacAlgSHA256),
iterations,
&outputBytes,
outputBytes.count
)

guard status == noErr else {
owsFailDebug("Unexpected status: \(status)")
return nil
}

return Data(outputBytes)
}

// MARK: - HMAC-SIV

private static let hmacsivIVLength = 16
Expand Down
2 changes: 0 additions & 2 deletions SignalCoreKit/src/OWSAsserts.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,4 @@ __attribute__((annotate("returns_localized_nsstring"))) static inline NSString *
OWSAssert(!_didOverflow); \
} while (NO)

void LogStackTrace(void);

NS_ASSUME_NONNULL_END
5 changes: 0 additions & 5 deletions SignalCoreKit/src/OWSAsserts.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ void SwiftExit(NSString *message, const char *file, const char *function, int li
[OWSSwiftUtils owsFail:message file:_file function:_function line:line];
}

void LogStackTrace()
{
[OWSSwiftUtils logStackTrace];
}

NS_ASSUME_NONNULL_END
69 changes: 0 additions & 69 deletions SignalCoreKit/src/OWSDataParser.swift

This file was deleted.

10 changes: 5 additions & 5 deletions SignalCoreKit/src/OWSSwiftUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public func owsFail(_ logMessage: String,
file: String = #file,
function: String = #function,
line: Int = #line) -> Never {
OWSSwiftUtils.logStackTrace()
logStackTrace()
owsFailDebug(logMessage, file: file, function: function, line: line)
let formattedMessage = owsFormatLogMessage(logMessage, file: file, function: function, line: line)
fatalError(formattedMessage)
Expand Down Expand Up @@ -96,8 +96,8 @@ public class OWSSwiftUtils: NSObject {
fatalError(formattedMessage)
}

@objc
public class func logStackTrace() {
Thread.callStackSymbols.forEach { Logger.error($0) }
}
}

public func logStackTrace() {
Logger.error(Thread.callStackSymbols.joined(separator: "\n"))
}
57 changes: 0 additions & 57 deletions SignalCoreKitTests/src/OWSDataParserTests.swift

This file was deleted.

0 comments on commit da1f1fd

Please sign in to comment.