Skip to content

Wrong encoding/decoding of default encryption password #1

Description

@ajpallares

Hello,

I found an issue in the code of SDOSEnvironment when using the -b flag in the SDOSEnvironment Build Phases script. The problem seems to be that the function generateDefaultPassword() returns an empty string, what causes a crash in the RNCryptor dependency.

This is the code where the error occurs:

private func generateDefaultPassword(bundle: Bundle = Bundle.main) -> String {
     let bundle = bundle.bundleIdentifier
     var password = ""
     var bytes = [UInt8]()
     if let bundle = bundle {
         let characters = Array(bundle)
         characters.forEach { (character) in
             var char = character.asciiValue ?? 0
             char += 7
             bytes.append(char)
         }
     }
     if let string = String(bytes: bytes, encoding: .utf8) {
         password = string
     }
        
     return password
 }

I believe the problem is that this code encodes using ascii but decodes using utf8. Changing the utf8 decoding to ascii should resolve the problem but I am not sure whether this is the intended behaviour.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions