mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Add X25519 conversion to Sodium
This commit is contained in:
parent
6430c36307
commit
6669f6a9d1
2 changed files with 45 additions and 0 deletions
|
@ -596,6 +596,7 @@
|
|||
C3DAB3242480CB2B00725F25 /* SRCopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */; };
|
||||
C3DFFAC623E96F0D0058DAF8 /* Sheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */; };
|
||||
C3DFFAC823E970080058DAF8 /* OpenGroupSuggestionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */; };
|
||||
C3E7134F251C867C009649BB /* Sodium+Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E7134E251C867C009649BB /* Sodium+Conversion.swift */; };
|
||||
CC875800737563D6891B741D /* Pods_SignalTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 748A5CAEDD7C919FC64C6807 /* Pods_SignalTests.framework */; };
|
||||
D202868116DBE0E7009068E9 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AEACDB16C426DA00C364C0 /* CFNetwork.framework */; };
|
||||
D202868216DBE0F4009068E9 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2179CFD16BB0B480006F3AB /* SystemConfiguration.framework */; };
|
||||
|
@ -1394,6 +1395,7 @@
|
|||
C3DAB3232480CB2A00725F25 /* SRCopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SRCopyableLabel.swift; sourceTree = "<group>"; };
|
||||
C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sheet.swift; sourceTree = "<group>"; };
|
||||
C3DFFAC723E970080058DAF8 /* OpenGroupSuggestionSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenGroupSuggestionSheet.swift; sourceTree = "<group>"; };
|
||||
C3E7134E251C867C009649BB /* Sodium+Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sodium+Conversion.swift"; sourceTree = "<group>"; };
|
||||
D17BB5C25D615AB49813100C /* Pods_Signal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Signal.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D2179CFB16BB0B3A0006F3AB /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
|
||||
D2179CFD16BB0B480006F3AB /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
|
@ -2691,6 +2693,7 @@
|
|||
C35E8AAD2485E51D00ACB629 /* IP2Country.swift */,
|
||||
B84664F4235022F30083A1CD /* MentionUtilities.swift */,
|
||||
B886B4A82398BA1500211ABE /* QRCode.swift */,
|
||||
C3E7134E251C867C009649BB /* Sodium+Conversion.swift */,
|
||||
B8783E9D23EB948D00404FB8 /* UILabel+Interaction.swift */,
|
||||
B83F2B87240CB75A000A54AB /* UIImage+Scaling.swift */,
|
||||
C31A6C59247F214E001123EF /* UIView+Glow.swift */,
|
||||
|
@ -3961,6 +3964,7 @@
|
|||
34D1F0831F8678AA0066283D /* ConversationInputTextView.m in Sources */,
|
||||
340FC8B6204DAC8D007AEB0F /* OWSQRCodeScanningViewController.m in Sources */,
|
||||
4CB5F26920F7D060004D1B42 /* MessageActions.swift in Sources */,
|
||||
C3E7134F251C867C009649BB /* Sodium+Conversion.swift in Sources */,
|
||||
340FC8B5204DAC8D007AEB0F /* AboutTableViewController.m in Sources */,
|
||||
34BECE2B1F74C12700D7438D /* DebugUIStress.m in Sources */,
|
||||
340FC8B9204DAC8D007AEB0F /* UpdateGroupViewController.m in Sources */,
|
||||
|
|
41
Signal/src/Loki/Utilities/Sodium+Conversion.swift
Normal file
41
Signal/src/Loki/Utilities/Sodium+Conversion.swift
Normal file
|
@ -0,0 +1,41 @@
|
|||
import Clibsodium
|
||||
import Sodium
|
||||
|
||||
extension Sign {
|
||||
|
||||
/**
|
||||
Converts an Ed25519 public key to an X25519 public key.
|
||||
- Parameter ed25519PublicKey: The Ed25519 public key to convert.
|
||||
- Returns: The X25519 public key if conversion is successful.
|
||||
*/
|
||||
public func toX25519(ed25519PublicKey: PublicKey) -> PublicKey? {
|
||||
var x25519PublicKey = PublicKey(repeating: 0, count: 32)
|
||||
|
||||
// FIXME: It'd be nice to check the exit code here, but all the properties of the object
|
||||
// returned by the call below are internal.
|
||||
let _ = crypto_sign_ed25519_pk_to_curve25519 (
|
||||
&x25519PublicKey,
|
||||
ed25519PublicKey
|
||||
)
|
||||
|
||||
return x25519PublicKey
|
||||
}
|
||||
|
||||
/**
|
||||
Converts an Ed25519 secret key to an X25519 secret key.
|
||||
- Parameter ed25519SecretKey: The Ed25519 secret key to convert.
|
||||
- Returns: The X25519 secret key if conversion is successful.
|
||||
*/
|
||||
public func toX25519(ed25519SecretKey: SecretKey) -> SecretKey? {
|
||||
var x25519SecretKey = SecretKey(repeating: 0, count: 32)
|
||||
|
||||
// FIXME: It'd be nice to check the exit code here, but all the properties of the object
|
||||
// returned by the call below are internal.
|
||||
let _ = crypto_sign_ed25519_sk_to_curve25519 (
|
||||
&x25519SecretKey,
|
||||
ed25519SecretKey
|
||||
)
|
||||
|
||||
return x25519SecretKey
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue