Util for generation RSA keys on your client and save to keychain or convert into Data πŸ”‘ πŸ”

Overview

RSASwiftGenerator πŸ”‘ πŸ”

CI Status Version License Platform

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements ⚠️

SWIFT 4

XCode 9 +

Installation πŸ“²

RSASwiftGenerator is available through CocoaPods. To install it, simply add the following line to your Podfile:

    pod 'RSASwiftGenerator'

Example πŸ’»

import UIKit
import RSASwiftGenerator

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        kRSASwiftGeneratorApplicationTag = "MY.BUNDLE.ID" //setup your id for keychain saving
        kRSASwiftGeneratorKeySize = 2048 //keySize
    // generade new key pair
        RSASwiftGenerator.shared.createSecureKeyPair() { (succes,error) in
            print(succes,error)
        }
        RSASwiftGenerator.shared.keyPairExists() // check keys for exist
        RSASwiftGenerator.shared.getPublicKeyData() // get  Data refference as public key
        RSASwiftGenerator.shared.getPublicKeyReference() // / get SecKey refference for public key
        RSASwiftGenerator.shared.getPrivateKeyReference() // get SecKey refference for private key
        RSASwiftGenerator.shared.deleteSecureKeyPair() { (succes) in
            print(succes)
        }// remove keys from keychain
    }

Author πŸ‘¨β€πŸ’»

Tarik, [email protected]

License

RSASwiftGenerator is available under the MIT license. See the LICENSE file for more info.

You might also like...
An easy way for hashing and encryption.
An easy way for hashing and encryption.

CatCrypto include a series of hashing and encryption functions and more functions in progress! CatCrypto also contains Swift bindings of Argon2, the p

A framework for the JOSE standards JWS, JWE, and JWK written in Swift.

JOSESwift is a modular and extensible framework for the JOSE standards JWS, JWE, and JWK written in Swift. πŸ’‘ Please note that this implementation of

BitWiser - A simple library to help you in dealing with bytes, bits and nibbles
BitWiser - A simple library to help you in dealing with bytes, bits and nibbles

BitWiser Bitwiser is a collection of methods and properties that makes you work

RSA public/private key generation, RSA, AES encryption/decryption, RSA sign/verify in Swift with CommonCrypto in iOS and OS X

SwCrypt Create public and private RSA keys in DER format let (privateKey, publicKey) = try! CC.RSA.generateKeyPair(2048) Convert them to PEM format l

JSONHelper - ✌ Convert anything into anything in one operation; JSON data into class instances, hex strings into UIColor/NSColor, y/n strings to booleans, arrays and dictionaries of these; anything you can make sense of!

JSONHelper Convert anything into anything in one operation; hex strings into UIColor/NSColor, JSON strings into class instances, y/n strings to boolea

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.

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

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.

Util for executing shell commands, and getting the results easily(data, string, and any decodable).

ShellExecutor Util for executing shell commands, and getting the results easily(data, string, and any decodable). Requirements Xcode 14.0+ Swift 5.7+

A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.
A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.

Keychain Manager Keychain Manager is a Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness

UICKeyChainStore is a simple wrapper for Keychain on iOS, watchOS, tvOS and macOS. Makes using Keychain APIs as easy as NSUserDefaults.

UICKeyChainStore UICKeyChainStore is a simple wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs as easy as NSUserDefaults. Lo

Keychain - Keychain wrapper with swift

Keychain wrapper. Store a value as a generic password: let account = "an-arbitra

Generate passwords and save them in Keychain. Made with SwiftUI.
Generate passwords and save them in Keychain. Made with SwiftUI.

lockd Generate strong passwords and save them in Keychain. Join lockd Beta on TestFlight: https://testflight.apple.com/join/xJ5AlvS3 Features: Generat

Generate strong passwords and save them in Keychain. Made with SwiftUI.
Generate strong passwords and save them in Keychain. Made with SwiftUI.

lockd Password manager iOS app, generate strong passwords and save them in Keychain. Download lockd on the App Store: https://apps.apple.com/us/app/lo

Save development time! Respresso automatically transforms and delivers your digital assets into your projects
Save development time! Respresso automatically transforms and delivers your digital assets into your projects

Introduction Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import the latest

Save development time! Respresso automatically transforms and delivers your digital assets into your projects
Save development time! Respresso automatically transforms and delivers your digital assets into your projects

Respresso Android client Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import

Save development time! Respresso automatically transforms and delivers your digital assets into your projects
Save development time! Respresso automatically transforms and delivers your digital assets into your projects

Respresso iOS client Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import the

PGPro can encrypt and decrypt messages as well as manage all your OpenPGP keys. It is free, simple and lightweight. Everything stays on your device. PGPro is made in Switzerland.
PGPro can encrypt and decrypt messages as well as manage all your OpenPGP keys. It is free, simple and lightweight. Everything stays on your device. PGPro is made in Switzerland.

PGPro can encrypt and decrypt messages as well as manage all your OpenPGP keys. It is free, simple and lightweight. Everything stays on your device. P

Video mp4 record save display - How to Take , Save and Display a .mp4 Video

Technicalisto How to Take , Save and Display a .mp4 Video Add your design with v

Save-the-dot-project-swift - Save the dot project with swift
Save-the-dot-project-swift - Save the dot project with swift

Save the Dot Apple introduced UIViewPropertyAnimator for iOS 10. We can use this

Comments
  • Problems with getting Private key as data

    Problems with getting Private key as data

    Hello, Nice library :). I am using it with other library meant for JWT -> https://github.com/IBM-Swift/Swift-JWT which uses your library for the part of generating private keys.

    Unfortunately, I am having some problems and I do not know is it this related to his or your library.

    You have methods

    let getPublicKeyData = RSASwiftGenerator.shared.getPublicKeyData()
    let getPublicKeyReference = RSASwiftGenerator.shared.getPublicKeyReference()
    let getPrivateKeyReference = RSASwiftGenerator.shared.getPrivateKeyReference()
    

    And I get an expected results from them (please see the attachment)

    here is the custom part I tried for getting private key as raw Data since there is no ".getPrivateKeyData()"

    var dataPtr:CFTypeRef?
            let query: [String: Any] = [
                kSecClass as String: kSecClassKey,
                kSecAttrApplicationTag as String: "MY.BUNDLE.ID",
                kSecReturnData as String: true
            ]
    
            let qResult = SecItemCopyMatching(query as CFDictionary, &dataPtr)
            let data = dataPtr as! Data
            let base64PublicKey = data.base64EncodedString()
    

    Then when I tried signing with privateKey my stuff, I get an error: SwiftJWT.JWTError(localizedDescription: "Provided private key could not be used to sign JWT", internalError: SwiftJWT.(unknown context at 0x10d9ae418).InternalError.invalidPrivateKey)

    I am not sure is it his library, yours or am I doing something wrong. Concretely, what do you advise on how to get private key as Data to be sure that part is working.

    opened by pavlem 4
  • I cannot get this pod installed on Catalina OSX 10.15.7

    I cannot get this pod installed on Catalina OSX 10.15.7

    When I do a pod install, I get the following error:

    [!] The platform of the target Tapo (macOS 10.15) is not compatible with RSASwiftGenerator (1.0.5), which does not support macOS.

    [!] Automatically assigning platform macOS with version 10.15 on target Tapo because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

    I am using Xcode version 12.4 and Swift 4.0 and the project format is set to ''Xcode 9.3-compatible".

    I am not very familiar with Xcode development, or swift, so I am probably doing something stupid wrong. I just want to make sure it should be possible to install this CocoaPod on this configuration before putting a lot of effort on getting this to work for me.

    The podfile has the following content:

    #Uncomment the next line to define a global platform for your project
    platform :osx, '10.15.7'
    
    target 'Tapo' do
      #Comment the next line if you don't want to use dynamic frameworks
      use_frameworks!
    
      #Pods for Tapo
    	    pod 'RSASwiftGenerator'
    
    end
    
    opened by RobertVoorn1977 0
Owner
IOS Software developer. Open-source contributor.
null
RSA public/private key encryption in Swift

SwiftyRSA Maintainer(s): @ikeith Public key RSA encryption in Swift. SwiftyRSA is used in the Scoop iOS app to encrypt driver license numbers before s

Scoop 1.1k Jan 5, 2023
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
A KeePass/Password Safe Client for iOS and OS X

Strongbox A Personal Password Manager for iOS & OSX that can be found on the Apple App Store here: https://apps.apple.com/app/strongbox-password-safe/

Strongbox 976 Jan 3, 2023
Secure your app by obfuscating all the hard-coded security-sensitive strings.

App Obfuscator for iOS Apps Secure your app by obfuscating all the hard-coded security-sensitive strings. Security Sensitive strings can be: REST API

pj 601 Dec 16, 2022
Safe and easy to use crypto for iOS and macOS

Swift-Sodium Swift-Sodium provides a safe and easy to use interface to perform common cryptographic operations on macOS, iOS, tvOS and watchOS. It lev

Frank Denis 483 Jan 5, 2023
A simple and opinionated AES encrypt / decrypt Objective-C class that just works.

AESCrypt-ObjC - Simple AES encryption / decryption for iOS and OS X AESCrypt is a simple to use, opinionated AES encryption / decryption Objective-C c

Gurpartap Singh 782 Oct 12, 2022
A tiny and easy to use Swift class to encrypt strings using HMAC algorithms.

#Sweet HMAC SweetHMAC is a tiny and easy to use Swift class to encrypt strings using HMAC algorithms. A special thanks to jernejstrasner for shared HM

Jan CΓ‘ssio 37 Jul 27, 2022
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift

CryptoSwift Crypto related functions and helpers for Swift implemented in Swift. (#PureSwift) Note: The main branch follows the latest currently relea

Marcin Krzyzanowski 9.4k Jan 9, 2023
Simple and secure hashing in Swift with the SipHash algorithm

SipHash ⚠️ WARNING This package has been obsoleted by the Hasher type and the Hashable.hash(into:) requirement introduced in Swift 4.2. Using this pac

null 262 Dec 19, 2022
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

null 3.3k Jan 7, 2023