RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

Last update: Jul 8, 2022

APIDoc Build Status - Master macOS iOS Linux Apache 2 Slack Status

BlueRSA

Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux (using OpenSSL) is working but is still somewhat of a work in progress.

Contents

  • CryptorRSA: Utility functions for RSA encryption and signing. Pure Swift

Prerequisites

Swift

  • Swift Open Source swift-4.0.0-RELEASE toolchain (Minimum REQUIRED for latest release)
  • Swift Open Source swift-4.2-RELEASE toolchain (Recommended)
  • Swift toolchain included in Xcode Version 10.0 (10A255) or higher.

macOS

  • macOS 10.12.0 (Sierra) or higher
  • Xcode Version 9.0 (9A325) or higher using the included toolchain (Minimum REQUIRED for latest release).
  • Xcode Version 10.0 (10A255) or higher using the included toolchain (Recommended).

iOS

  • iOS 10.3 or higher
  • Xcode Version 9.0 (9A325) or higher using the included toolchain (Minimum REQUIRED for latest release).
  • Xcode Version 10.0 (10A255) or higher using the included toolchain (Recommended).

Linux

  • Ubuntu 16.04 (or 16.10 but only tested on 16.04) and 18.04.
  • One of the Swift Open Source toolchain listed above.
  • OpenSSL is provided by the distribution. Note: 1.0.x, 1.1.x and later releases of OpenSSL are supported.
  • The appropriate libssl-dev package is required to be installed when building.

Build

To build CryptorRSA from the command line:

% cd <path-to-clone>
% swift build

Testing

To run the supplied unit tests for CryptorRSA from the command line:

% cd <path-to-clone>
% swift build
% swift test

Using CryptorRSA

Including in your project

Swift Package Manager

To include BlueRSA into a Swift Package Manager package, add it to the dependencies attribute defined in your Package.swift file. You can select the version using the majorVersion and minor parameters. For example:

	dependencies: [
		.Package(url: "https://github.com/Kitura/BlueRSA", majorVersion: <majorVersion>, minor: <minor>)
	]

Carthage

To include BlueRSA in a project using Carthage, add a line to your Cartfile with the GitHub organization and project names and version. For example:

	github "Kitura/BlueRSA" ~> <majorVersion>.<minor>

Before starting

The first you need to do is import the CryptorRSA framework. This is done by the following:

import CryptorRSA

Data Types

BlueRSA supports the following major data types:

  • Key Handling

    • CryptorRSA.PublicKey - Represents an RSA Public Key.
    • CryptorRSA.PrivateKey - Represents an RSA Private Key.
  • Data Handling

    • CryptorRSA.EncryptedData - Represents encrypted data.
    • CryptorRSA.PlaintextData - Represents plaintext or decrypted data.
    • CryptorRSA.SignedData - Represents signed data.

Key Handling

BlueRSA provides seven (7) functions each for creating public and private keys from data. They are as follows (where createXXXX is either createPublicKey or createPrivateKey depending on what you're trying to create):

  • CryptorRSA.createXXXX(with data: Data) throws - This creates either a private or public key containing the data provided. It is assumed that the data being provided is in the proper format.
  • CryptorRSA.createXXXX(withBase64 base64String: String) throws - This creates either a private or public key using the Base64 encoded String provided.
  • CryptorRSA.createXXXX(withPEM pemString: String) throws - This creates either a private or public key using the PEM encoded String provided.
  • CryptorRSA.createXXXX(withPEMNamed pemName: String, onPath path: String) throws - This creates either a private or public key using the PEM encoded file pointed at by the pemName and located on the path specified by path provided.
  • CryptorRSA.createXXXX(withDERNamed derName: String, onPath path: String) throws - This creates either a private or public key using the DER encoded file pointed at by the derName and located on the path specified by path provided.
  • CryptorRSA.createXXXX(withPEMNamed pemName: String, in bundle: Bundle = Bundle.main) throws - This creates either a private or public key using the PEM encoded file pointed at by the pemName and located in the Bundle specified by bundle provided. By default this API will look in the main bundle. Note: Apple Platforms Only
  • CryptorRSA.createXXXX(withDERNamed derName: String, in bundle: Bundle = Bundle.main) throws - This creates either a private or public key using the DER encoded file pointed at by the derName and located in the Bundle specified by bundle provided. By default this API will look in the main bundle. Note: Apple Platforms Only

Additionally, there are three APIs for creating a public key by extracting the key from a PEM formatted certificate: They are:

  • CryptorRSA.createPublicKey(extractingFrom data: Data) throws - This creates either a public key by extracting from the PEM encoded certificate pointed at by the data.
  • CryptorRSA.createPublicKey(extractingFrom certName: String, onPath path: String) throws - This creates a public key by extracting from the PEM encoded certificate pointed at by the certName and located on the path specified by path provided.
  • CryptorRSA.createPublicKey(extractingFrom certName: String, in bundle: Bundle = Bundle.main) throws - This creates a public key using the PEM encoded certificate pointed at by the derName and located in the Bundle specified by bundle provided. By default this API will look in the main bundle. Note: Apple Platforms Only

Example

The following example illustrates creating a public key given PEM encoded file located on a certain path. *Note: Exception handling omitted for brevity.

import Foundation
import CryptorRSA

...

let keyName = ...
let keyPath = ...

let publicKey = try CryptorRSA.createPublicKey(withPEMNamed: keyName, onPath: keyPath)

...

<Do something with the key...>

Data Encryption and Decryption Handling

BlueRSA provides functions for the creation of each of the three (3) data handling types:

Plaintext Data Handling and Signing

There are two class level functions for creating a PlaintextData object. These are:

  • CryptorRSA.createPlaintext(with data: Data) -> PlaintextData - This function creates a PlaintextData containing the specified data.
  • CryptorRSA.createPlaintext(with string: String, using encoding: String.Encoding) throws -> PlaintextData - This function creates a PlaintextData object using the string encoded with the specified encoding as the data.

Once the PlaintextData object is created, there are two instance functions that can be used to manipulate the contained data. These are:

  • encrypted(with key: PublicKey, algorithm: Data.Algorithm) throws -> EncryptedData? - This function allows you to encrypt containing data using the public key and algorithm specified. This function returns an optional EncryptedData object containing the encryped data.
  • signed(with key: PrivateKey, algorithm: Data.Algorithm) throws -> SignedData? - This function allows you to sign the contained data using the private key and algorithm specified. This function returns an optional SignedData object containing the signature of the signed data.

Example

  • Encryption: Note: Exception handling omitted for brevity.
import Foundation
import CryptorRSA

...

let keyName = ...
let keyPath = ...

let myData: Data = <... Data to be encrypted ...>

let publicKey = try CryptorRSA.createPublicKey(withPEMNamed: keyName, onPath: keyPath)
let myPlaintext = CryptorRSA.createPlaintext(with: myData)
let encryptedData = try myPlaintext.encrypt(with: publicKey, algorithm: .sha1)

...

< Do something with the encrypted data...>

  • Signing: Note: Exception handling omitted for brevity.
import Foundation
import CryptorRSA

...

let keyName = ...
let keyPath = ...

let myData: Data = <... Data to be signed ...>

let privateKey = try CryptorRSA.createPrivateKey(withPEMNamed: keyName, onPath: keyPath)
let myPlaintext = CryptorRSA.createPlaintext(with: myData)
let signedData = try myPlaintext.signed(with: privateKey, algorithm: .sha1)

...

< Do something with the signed data...>

Encrypted Data Handling

There are two class level functions for creating a EncryptedData object. These are:

  • CryptorRSA.createEncrypted(with data: Data) -> EncryptedData - This function creates a EncryptedData containing the specified encrypted data.
  • CryptorRSA.createEncrypted(with base64String: String) throws -> EncryptedData - This function creates a EncrpytedData using the Base64 representation of already encrypted data.

Once the EncryptedData object is created, there is an instance function that can be used to decrypt the enclosed data:

  • decrypted(with key: PrivateKey, algorithm: Data.Algorithm) throws -> DecryptedData? - This function allows you to decrypt containing data using the public key and algorithm specified. This function returns an optional DecryptedData object containing the encryped data.

BlueRSA currently supports OAEP padding, which is the recommended padding algorithm.

Example

  • Decryption: Note: Exception handling omitted for brevity.
import Foundation
import CryptorRSA

...

let keyName = ...
let keyPath = ...
let publicKey = try CryptorRSA.createPublicKey(withPEMNamed: keyName, onPath: keyPath)

let pkeyName = ...
let pkeyPath = ...
let privateKey = try CryptorRSA.createPrivateKey(withPEMNamed: pkeyName, onPath: pkeyPath)

let myData: Data = <... Data to be encrypted ...>

let myPlaintext = CryptorRSA.createPlaintext(with: myData)
let encryptedData = try myPlaintext.encrypt(with: publicKey, algorithm: .sha1)

let decryptedData = try encryptedData.decrypt(with: privateKey, algorithm: .sha1)

...

< Do something with the decrypted data...>


Signature Verification Handling

There is a single class level function that can be used to create a SignedData object. It is:

  • CryptorRSA.createSigned(with data: Data) -> SignedData - This function creates a SignedData containing the specified signed data.

Once created or obtained PlaintextData and SignedData, there is an instance function which can be used to verify the signature contained therein:

  • verify(with key: PublicKey, signature: SignedData, algorithm: Data.Algorithm) throws -> Bool - This function is used to verify, using the public key and algorithm, the signature. Returns true if the signature is valid, false otherwise.

  • Verifying: Note: Exception handling omitted for brevity.

import Foundation
import CryptorRSA

...

let keyName = ...
let keyPath = ...
let publicKey = try CryptorRSA.createPublicKey(withPEMNamed: keyName, onPath: keyPath)

let pkeyName = ...
let pkeyPath = ...
let privateKey = try CryptorRSA.createPrivateKey(withPEMNamed: pkeyName, onPath: pkeyPath)

let myData: Data = <... Data to be signed ...>

let myPlaintext = CryptorRSA.createPlaintext(with: myData)
let signedData = try myPlaintext.signed(with: privateKey, algorithm: .sha1)

if try myPlaintext.verify(with: publicKey, signature: signedData, algorithm: .sha1) {

	print("Signature verified")

} else {

	print("Signature Verification Failed")
}

Data Type Utility Functions

All three of the data handling types have two common utility instance functions. These are:

  • digest(using algorithm: Data.Algorithm) throws -> Data - This function returns a Data object containing a digest constructed using the specified algorithm.
  • string(using encoding: String.Encoding) throws -> String - This functions returns a String representation of the data using the specified encoding.

Community

We love to talk server-side Swift and Kitura. Join our Slack to meet the team!

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

GitHub

https://github.com/IBM-Swift/BlueRSA
Comments
  • 1. Use SecCertificateCopyKey API when available, falling back in edge cases

    SecCertificateCopyPublicKey is deprecated in iOS 12 and macOS 10.14 in favor of SecCertificateCopyKey. This change introduces the use of the new API for all platforms that support it.

    Description

    Simply uses the new API when available and falls back to the legacy API when not. Keeps support for pre-4.2 Swift, but wraps everything in compiler directives to allow builds on platforms that have no reference to the deprecated API.

    The changes to the xcode project are from opening the project in a newer version of XCode. Content from 9.3 release notes:

    Xcode 9.3 adds a new IDEWorkspaceChecks.plist file to a workspace's shared data, to store the state of necessary workspace checks. Committing this file to source control will prevent unnecessary rerunning of those checks for each user opening the workspace. (37293167)

    Motivation and Context

    Previous to this patch, BlueRSA did not compile on macOS Catalyst. There is an existing pull request open, but the author has not responded in some time. Moreover, it appears SecCertificateCopyKey is already used for clients that support it, however, the codepath using the deprecated API was not wrapped in a compiler directive and the compiler still failed.

    Resolves #59

    How Has This Been Tested?

    Built and run on macOS and iOS. Ran tests on the macOS target.

    Checklist:

    • [x] I have submitted a CLA form
    • [x] If applicable, I have updated the documentation accordingly.
    • [x] If applicable, I have added tests to cover my changes.
    Reviewed by levi at 2020-01-17 17:00
  • 2. Removes unneeded CFString: Hashable extension

    Starting with starting with Swift 4.0 all CF types already conform to Hashable. Therefore this extension is not needed anymore.

    Description

    Pre Swift 4.0 this extension was required but since the minimal swift version of this package is 4.0 this part of the code is not needed anymore. The corresponding implementation in the swift stdlib can be found here.

    Motivation and Context

    Recent changes in the Swift runtime indicate that the order in which protocol conformances are loaded is not guaranteed and might change with swift 5.4 which will ship with the upcoming Xcode release (12.5). Therefore the CFString extension of this package might produce unwanted side-effects for the application which is using this package.

    How Has This Been Tested?

    Built and run on macOS and iOS. Ran tests on the macOS target.

    Reviewed by stmitt at 2021-02-09 23:02
  • 3. fix: Added deallocate functions

    We had reports of a memory leak when using this repo on Linux. I have tracked down places where we allocate memory and added deallocate functions to fix the leaks.

    Reviewed by Andrew-Lees11 at 2019-02-25 11:55
  • 4. Compatability changes for Catalyst

    In order to use this package in catalyst projects SecCertificateCopyPublicKey was deprecated and needed to change to the supported Method SecCertificateCopyKey(certData) Method.

    Description

    In order to use this package in catalyst projects SecCertificateCopyPublicKey was deprecated and needed to change to the supported Method SecCertificateCopyKey(certData) Method.

    Resources: Deprecation - https://developer.apple.com/documentation/security/1396096-seccertificatecopypublickey New Method - https://developer.apple.com/documentation/security/2963103-seccertificatecopykey

    Motivation and Context

    I'd like to use it in my macOS, iPadOS and iOS project suppored by Catalyst.

    How Has This Been Tested?

    I have a project which has iOS, iPadOS and macOS as deployment targets. I use the deployment version iOS 13.1 and macOS 10.15 (catalina). The dependency management is Swift Package Manager. My dynamic framwork has the SwiftJWT package as dependency and uses BlueRSA in order to create the JWT.

    Building and running the project on iOS works fine but macOS catalyst does not know the deprecated method SecCertificateCopyPublicKey. Since catalyst the new method SecCertificateCopyKey has to be used in order to support catalyst.

    Resources: Deprecation - https://developer.apple.com/documentation/security/1396096-seccertificatecopypublickey New Method - https://developer.apple.com/documentation/security/2963103-seccertificatecopykey

    Checklist:

    • [ ] I have submitted a CLA form (Just changed to the new method and remove the deprecation.)
    • [x] If applicable, I have updated the documentation accordingly. (no changes necessary)
    • [x] If applicable, I have added tests to cover my changes. (see above)
    Reviewed by sn3ek at 2019-10-02 21:01
  • 5. iOS not supported in the podspec

    When trying to use the BlueRSA pod for iOS I get the following error:

    The platform of the target `CocoapodsTest` (iOS 12.0) is not compatible with `BlueRSA (1.0.17)`, which does not support `ios`
    

    when comparing the podspec of BlueRSA to BlueCryptor I saw that:

    s.ios.deployment_target = "10.0"
    

    Was missing. In the readme it states the BlueRSA runs on iOS 10 or higher so I would expect this to work.

    There is not a reference to the BlueRSA pod but I assume it is intended to support this?

    Reviewed by Andrew-Lees11 at 2018-11-19 14:16
  • 6. feat: Add PSS signing and verifying

    Description

    This pull request adds usePSS flag to sign and verify. This allows you to use RSA-PSS for signing and verifying. If the flag is set to true the functions will use RSA_PKCS1_PSS_PADDING, a salt the length of the digest and MGF1 mask generation function to sign or verify.

    Motivation and Context

    This change is required because "In general, RSA-PSS should be used as a replacement for RSA-PKCS#1 v1.5".

    It also allows us to support PS256 and PS384 signing/verifying with JWTs as requested by SwiftJWT issue #55

    How Has This Been Tested?

    Tests have been added covering the new algorithms and the produced signatures have been tested against JWT.io both that one we create is valid and we can verify a valid one created by JWT.io.

    Checklist:

    • [x] I have submitted a CLA form
    • [x] If applicable, I have updated the documentation accordingly.
    • [x] If applicable, I have added tests to cover my changes.
    Reviewed by Andrew-Lees11 at 2019-05-07 15:28
  • 7. Crash while creating private key with Base64 string on Linux

    I removed header and footer lines in my private key file and use:

    let privateKey = try CryptorRSA.createPrivateKey(withBase64: base64String)

    it works well on Mac OS but on Linux it crashes with error:

    Fatal error: Unexpectedly found nil while unwrapping an Optional value

    Reviewed by Luzanov at 2019-02-27 11:15
  • 8. Encrypted data cannot be shared between MacOS and Linux

    When you encrypt some data using a public key on MacOS into an Encrypted data, you can decrypt this data on MacOS, However if you try to decrypt the same data on Linux it doesn't work. This means that is data is encrypted on MacOS it cannot be decrypted on Linux.

    You can replicate this with the following code:

    let publicKey = """
    -----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDpbnF5g5bt9mjweE5nZioLAPKI
    l31qj5/ht4i62gsEg/6R/GMBIAhUEgfr9n3H0jIKRoI0BvVH6+fUB9pKoMUdRu3V
    sAF9ExkuhwazpE1uIfRbf2IJHIAz5zX3emUdymHaPZPucQUF7G/XmOMK86qKl8Zd
    d8Gl8cTFpRVMoSs4lwIDAQAB
    -----END PUBLIC KEY-----
    """
    
    let privateKey = """
    -----BEGIN RSA PRIVATE KEY-----
    MIICXQIBAAKBgQDpbnF5g5bt9mjweE5nZioLAPKIl31qj5/ht4i62gsEg/6R/GMB
    IAhUEgfr9n3H0jIKRoI0BvVH6+fUB9pKoMUdRu3VsAF9ExkuhwazpE1uIfRbf2IJ
    HIAz5zX3emUdymHaPZPucQUF7G/XmOMK86qKl8Zdd8Gl8cTFpRVMoSs4lwIDAQAB
    AoGAcs/ZjDTGxWAPGUdy+LRtNWBP6hLoosLllnVZEN4x0RTC3zbN0z3YGtGLh+mC
    0Ad4iUlIvSI2/hrvuX/rRA1zJRSWqmUi+K/IQtRqH4L29xfDT9yxVd5X61vb5dGs
    nruBHBSdcfsLKrQZClAqGKNElVfLn5+vaf48hsm9de5lSRECQQD+WcQHRSEyuuWl
    dW0qhfRBXjtqnvS1VQ+CmS4nzeAVfNLV8KzJvx/evoQ9KxbnwfN/fQkyniK0RzNs
    kcXNZFsLAkEA6vHzWrQVtiQ5b8itwn3er7FWWy53SFLiy2MJCUBmm0Z2uJXox4Ym
    nH2SoUVMHJOvqgdqcwz53RJIlMPkAMgwJQJAbYTDZon6qHhXR65PSh8RtE/Z76fw
    IGA25HoGqLb6BOaRdfNCwz/bfjK0iA4Ut8gIi92P5062DMAXwWjnLfBHTwJBAM0E
    p2xeO5f+0lQ2lVJkDj/Yi1f0G0j0c04yNL9rAF69RXpb7o62BNmIRr0OQJWrVp4T
    7JNLHnsIqmeO7Va1WjUCQQDcY8s947hfiISXQ9o6auz33WyIRQWt/x0WdujVsxjM
    JNHkkGxCfEjy9Z74EO8MoSddiM4+u7gPZsr5f6AZvMsj
    -----END RSA PRIVATE KEY-----
    """
    
    // Generate encrypted data
    let key = try CryptorRSA.createPublicKey(withPEM: publicKey)
                let plaintext = try CryptorRSA.createPlaintext(with: "Hello World", using: .utf8)
                let encrypted = try plaintext.encrypted(with: key, algorithm: .sha256)
    
    // encrypted.base64String on linux (216 char)
    let linuxEncryptedHelloWorld = "VyG6sYjAAH3FtuOfN5BJWnScjVl5gAXTfThXbFNA0pU50pgPXEffV+T/4e9CchWHp6/8gpKNfuP7J2ly5577zwxnsLTHU3K2VlH2eq4UMEmKi3aZ9sUVzea3I5xvIoBVK0JVluNW4Wjld8Er1dB/1ZDwN94Qq9/TamNhiTD4a10XN5byzBn5D+lOFJ6RTk16Z4svXV3OjjvANYowxvXIeg=="
    
    // encrypted.base64String on mac (208 char)
    let macEncryptedHelloWorld = "JaLeZ4VhVoAENpa7EZZhsUpm2YmzfG9L496m0rtau4vR6wGKZ432l0xcfOkYjZeGN93/Fav82VNQEDonrWCUjEQuiodapbyne2r3HElhPwbbtEBVqeSI3XmJwTE8PH3Q7qGH9DxPxZf0dEhQAyoYNKQHVr4vumYanDNR+rGSvIQqPW37+JIt1zb0wjFaJVRUUsB8ELQzRD0yogM="
    
    if let decryptedString = self.decrypt(base64EncryptedData: linuxEncryptedHelloWorld) {
        print("Successfully decrypted the Linux encrypted word: \(decryptedString)")
    }
    if let decryptedString = self.decrypt(base64EncryptedData: macEncryptedHelloWorld) {
        print("Successfully decrypted the Mac encrypted word: \(decryptedString)")
    }
    // Only the operating system you are currently running will be able to decode the encrypted word
    

    On linux OpenSSL envelopes are used similar to this article On mac Security is used similar to this article

    I did notice that the aes digest is different here. However, when you change to EVP_aes_128_gcm() the test fail.

    Reviewed by Andrew-Lees11 at 2019-01-14 16:53
  • 9. Fix for Ubuntu 14.04 and OpenSSL 1.0.1

    There is an issue where systems using an older version of OpenSSL are not able to build, due to a type mismatch. The PR links to a branch I have made of the OpenSSL module map which now has a wrapper around the method in question (EVP_DigestVerifyFinal) to stop Swift complaining due to a type mismatch.

    When the OpenSSL branch is merged into master, I will update this PR to point to the release that contains the fix, rather than the branch. Opening this now so Travis can do some testing.

    Reviewed by KyeMaloy97 at 2018-07-25 15:11
  • 10. New Release

    Would it be possible to create a new release that contains https://github.com/Kitura/BlueRSA/pull/70.

    Our Project is using https://github.com/Kitura/Swift-JWT which references this repository. Therefore we need a new version of this package to be published in order that the fix will get included.

    Thanks for your work.

    Reviewed by stmitt at 2021-03-05 09:47
  • 11. Update iOS available version to 10.3

    Description

    A user was trying to build Swfit-JWT using Carthage and it wouldn't compile. They raised issue #64 which shows the compile error that:

    'SecCertificateCopyPublicKey' is only available on iOS 10.3 or newer
    

    This fix updates the @available tag to be:

    @available(macOS 10.12, iOS 10.3, *)
    

    Which allows the project to compile.

    How Has This Been Tested?

    The project was compiled and tested using the iOS simulator.

    Reviewed by Andrew-Lees11 at 2019-06-26 12:42
  • 12. creating a symmetric public/private key

    Hi there,

    can I use this lib also to generate a certificate with a private key that was created? Something like:

    let keypair = try CryptorRSA.makeKeyPair(CryptorRSA.RSAKey.KeySize.bits2048)
    var cert = createCertificate()
    cert.publicKey = keypair.publicKey
    cert.sign(keypair.privateKey, sha256)
    

    is it possible? thanks

    Reviewed by SodaSurfer at 2022-01-21 12:03
  • 13. Linux. Crash when decrypting: "Fatal error: Can't form Range with upperBound < lowerBound"

    OS: Linux OpenSSL Version: 1.1.1

    I am using the same exact code on MacOS and on Linux:

    guard let decryptedData = try CryptorRSA.createEncrypted(with: data).decrypted(with: privateKey, algorithm: .sha1)?.data
    

    I am attempting to decrypt data with a private key. It works properly on MacOS, but when running on Linux I get a crash with error:

    Fatal error: Can't form Range with upperBound < lowerBound: file Swift/Range.swift, line 728
    

    I noticed this is coming from line 697 in Sources/CryptorRSA.swift during the step with the comment "Extract encryptedKey, encryptedData, encryptedIV from data"

    Reviewed by ksinghal at 2021-04-22 21:19
  • 14. what is error code -50?

    getting this error when trying to decrypt.

    Error Domain=NSOSStatusErrorDomain Code=-50 "RSA-WRAP too short input data" UserInfo={NSDescription=RSA-WRAP too short input data}

    how should I resolve it????

    Reviewed by MohsenMoghimi at 2020-06-28 11:51
  • 15. Bug: strange path resolving in createXXXXX (withPEMNamed pemName: String, onPath path: String)

    I may misunderstand something here, but when I build my the project the following code fails: try CryptorRSA.createPrivateKey(withPEMNamed: "private.pem", onPath: "/Resources/")

    trying to find the key file at that path: <path_to_xcode_project_derived_data>/SourcePackages/checkouts/BlueRSA/Sources/CryptorRSA/CryptorRSAKey.swift/Resources/private_key.pem

    Code causing the problem in createPrivateKey function: let fullPath = URL(fileURLWithPath: #file).appendingPathComponent( path.appending(certName) ).standardized Is appending path to CryptorRSAKey.swift file is supposed to be working?

    Workaround is to get the content of a .pem file yourself: try CryptorRSA.createPrivateKey(withPEM: privateKey())

    The same problem with any createXXXXX (pemName/derName, onPath) function.

    Reviewed by HashedViking at 2020-02-04 11:20
  • 16. Illegal Instruction (core dumped) createPublicKey(...) on Ubuntu

    BlueRSA failed to create data from base64 string on Ubuntu. The illegal instruction is from the forced unwrap of the Data object, which is nil. Running on MacOS this works without any problems.

    Screenshot 2019-11-12 13 25 01

    I added extra Log lines in CryptorRSAKey to find this bug.

    Screenshot 2019-11-12 13 21 23

    Reviewed by geertberkers at 2019-11-12 12:28
A customizable verification code textField. Can be used for phone verification codes, passwords etc
A customizable verification code textField. Can be used for phone verification codes, passwords etc

KKPinCodeTextField A customizable verification code textField. Can be used for phone verification codes, passwords etc. Настраиваемое текстовое поле д

Jul 5, 2022
Swift RSA Key Loader

Swift RSA Key Loader Requirements iOS 9.0+ Installation See the subsections below for details about the different installation methods. Swift Package

Jun 13, 2022
Private Password Manager developped with Swift for iOS project.
Private Password Manager developped with Swift for iOS project.

Private Password Manager developped with Swift for iOS project. This manager can syncronize secret data to Azure Blob Storage. To specify user account, tSecret use Azure Active Directory authentication.

Dec 3, 2021
RSA encrypt and decrypt in Swift

MZRSA_Swift MZRSA_Swift是一个轻量级框架,框架功能包含RSA加密/解密Data、RSA加密/解密String,支持字符串密钥和证书密钥 公钥加密&私钥解密(字符串密钥) 代码示例 let PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8

Jul 15, 2022
Wrapper class for handling all tasks related to RSA cryptography

RSAWrapper Wrapper class for handling all tasks related to RSA cryptography USAG

Dec 24, 2021
CCCryptor (AES encryption) wrappers for iOS and Mac in Swift. -- For ObjC, see RNCryptor/RNCryptor-objc

RNCryptor Cross-language AES Encryptor/Decryptor data format. The primary targets are Swift and Objective-C, but implementations are available in C, C

Aug 6, 2022
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.

KeychainAccess KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs extremely easy and much mor

Aug 3, 2022
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works.

Valet Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. It’s easy.

Aug 3, 2022
A wrapper to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

A wrapper (written only in Swift) to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

Mar 29, 2022
iOS library for device fingerprinting. Does not require server APIs to work, fully client-side operation.
iOS library for device fingerprinting. Does not require server APIs to work, fully client-side operation.

Lightweight iOS library for local device fingerprinting Installation (CocoaPods) # Podfile pod 'FingerprintJS' Note: If you've never used CocoaPods fo

Jul 26, 2022
Native and encrypted password manager for iOS and macOS.
Native and encrypted password manager for iOS and macOS.

Open Sesame Native and encrypted password manager for iOS and macOS. What is it? OpenSesame is a free and powerful password manager that lets you mana

Aug 6, 2022
Apple's iOS Private Frameworks
Apple's iOS Private Frameworks

iOS Private Framework This repo contains reversed-engendered private frameworks used by Apple in iOS. Private frameworks are frameworks which you are

Feb 21, 2022
Simple Objective-C wrapper for the keychain that works on Mac and iOS

SAMKeychain SAMKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keyc

Aug 1, 2022
Send key events to any running macOS application.

KeySender An extremely simple micro package that enables you to send key events to any running application. Install Add the following to your Package.

Jul 31, 2022
Swift OpenSSL for OS X and Linux

OpenSSL OpenSSL for Swift 3.0. Installation import PackageDescription let package = Package( dependencies: [ .Package(url: "https://github.com/Zew

Aug 6, 2022
KeePassium is a KeePass-compatible password manager for iOS
KeePassium is a KeePass-compatible password manager for iOS

KeePassium is a KeePass-compatible password manager for iOS. It offers automatic database synchronization, respect to privacy and premium user experience.

Aug 9, 2022
A key value store for storing per-developer environment and application keys

A key value store for enviroment and application keys. Its good security practice to keep production keys out of developer hands. CocoaPods-keys makes

Jul 13, 2022
Swift Key Derivation

KeyDerivation This package implements key derivation system based of 5 levels: m / purpose' / coin_type' / account' / role / index As described in CIP

Mar 5, 2022
A really simple key-value wrapper for keychain.

PlainKeychain A really simple key-value wrapper for keychain. Features ✅ Key-value pairs using kSecClassGenericPassword. ❌ Internet passwords (kSecCla

Nov 27, 2021