Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation error codes #507

Closed
Invariant0x opened this issue Feb 6, 2023 · 5 comments
Closed

Documentation error codes #507

Invariant0x opened this issue Feb 6, 2023 · 5 comments

Comments

@Invariant0x
Copy link

Where I can find code errors?
I sometimes get LibSignalClient.SignalError, error 22 In group decrypt
What is it mean?
Please help

@jrose-signal
Copy link
Contributor

There should be no numeric error codes visible in libsignal's Swift interface. How are you using this code and where are you seeing the error?

@Invariant0x
Copy link
Author

Invariant0x commented Feb 6, 2023

here is an example of my code
Moreover, I often get error 18, but it is not in the Signal description

private func initProtocolStore() throws {
   print("initProtocolStore", "remoteAddress", remoteAddress?.name)
   guard let remoteAddress else { return }
   print("initProtocolStore", "remoteAddress", remoteAddress.name)
   
   print("initProtocolStore", "senderSKDM", senderSkdm)
//    let skdm_r = try SenderKeyDistributionMessage(from: remoteAddress,
//                                                  distributionId: groupId,
//                                                  store: store,
//                                                  context: NullContext())
   
   guard let dataSkdm = Data(base64Encoded: senderSkdm) else { return }
   let skdm_r = try SenderKeyDistributionMessage(bytes: [UInt8](dataSkdm))
   
   print("initProtocolStore", "skdm_r", skdm_r)
   try processSenderKeyDistributionMessage(
     skdm_r,
     from: remoteAddress,
     store: store,
     context: NullContext()
   )
   print("initProtocolStore", "processSenderKeyDistributionMessage", "Ok")
 }

 func encrypt(message : String) throws -> Data? {
   let buf = [UInt8](message.utf8)
   
   let cipherTextMessage =  try groupEncrypt(
     buf,
     from: localAddress,
     distributionId: groupId,
     store: store,
     context: NullContext()
   )
   
   print("encryped type message = \(cipherTextMessage.messageType)")
   
   return Data(cipherTextMessage.serialize())
 }
 
 /// Расшифровка сообщений в группе
 func decrypt(message : Data) throws -> String? {
   guard let remoteAddress else { return nil }
   print("decrypt", "remoteAddress", remoteAddress)
   try self.initProtocolStore()
 
   print("decrypt", "initProtocolStore")
   let b_ptext = try groupDecrypt(
     message,
     from: remoteAddress,
     store: store,
     context: NullContext()
   )
   print("decrypt", "b_ptext", b_ptext)
   
   return String(bytes: b_ptext, encoding: String.Encoding.utf8)
 }

@jrose-signal
Copy link
Contributor

Hm, this code seems reasonable at first glance. Where are you seeing the number, though? Is it just print(error) in a catch block? None of the errors should have numbers printed.

@Invariant0x
Copy link
Author

let b_ptext = try groupDecrypt(
     message,
     from: remoteAddress,
     store: store,
     context: NullContext()
   )

Error 18 In this function

Maybe Can I use this function try processSenderKeyDistributionMessage only once? Now I call it in decrypt function every time Is it correct?

@jrose-signal
Copy link
Contributor

The distribution message should be sent over a separate encrypted channel and processed once, yes, but I wouldn't expect an error for processing it repeatedly…though perhaps the error you're seeing is "duplicatedMessage", which you can get if the sender side isn't preserving their session state across multiple messages.

Where are the error numbers printed? None of these errors have numbers.

@jrose-signal jrose-signal closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants