Skip to content

Commit

Permalink
RSA documentation (encrypt/decrypt/generation)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfallet committed Sep 28, 2021
1 parent 0bb23e3 commit 14e3c3e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,33 @@ let encrypt = try AEADChaCha20Poly1305.encrypt(plaintext, key: key, iv: nonce, a
let decrypt = try AEADChaCha20Poly1305.decrypt(ciphertext, key: key, iv: nonce, authenticationHeader: header, authenticationTag: tagArr: tag)
```

##### RSA

RSA initialization from parameters

```swift
let input: Array<UInt8> = [0,1,2,3,4,5,6,7,8,9]

let n: Array<UInt8> = // RSA modulus
let e: Array<UInt8> = // RSA public exponent
let d: Array<UInt8> = // RSA private exponent

let rsa = RSA(n: n, e: e, d: d)

do {
let encrypted = try rsa.encrypt(input)
let decrypted = try rsa.decrypt(encrypted)
} catch {
print(error)
}
```

RSA key generation

```swift
let rsa = RSA(keySize: 2048) // This generates a modulus, public exponent and private exponent with the given size
```

## Author

CryptoSwift is owned and maintained by [Marcin Krzyżanowski](http://www.krzyzanowskim.com)
Expand Down
4 changes: 2 additions & 2 deletions Sources/CryptoSwift/RSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public final class RSA {
self.init(n: n, e: e, d: d)
}

// TODO: Add initializer from PEM (ASN.1 with DER header)
// TODO: Add initializer from PEM (ASN.1 with DER header) (See #892)

// TODO: Add export to PEM (ASN.1 with DER header)
// TODO: Add export to PEM (ASN.1 with DER header) (See #892)

}

Expand Down

0 comments on commit 14e3c3e

Please sign in to comment.