All Projects → vpeschenkov → Securedefaults

vpeschenkov / Securedefaults

Licence: mit
A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Securedefaults

cryptalk
HTML5/Node.js based, client side (E2EE) encrypted instant chat
Stars: ✭ 73 (-59.22%)
Mutual labels:  aes, aes-encryption
libVES.c
VESvault End-to-End Encryption API: Encrypt Everything Without Fear of Losing the Key
Stars: ✭ 28 (-84.36%)
Mutual labels:  aes, aes-encryption
PassLock
PassLock is a medium-security password manager that encrypts passwords using Advanced Encryption Standards (AES)
Stars: ✭ 44 (-75.42%)
Mutual labels:  aes, aes-encryption
Aescipher Ios
AES encryption working between Objective-C and Java.
Stars: ✭ 198 (+10.61%)
Mutual labels:  aes, aes-encryption
Cross Platform Aes
Simple cross-platform encryption and decryption using AES
Stars: ✭ 127 (-29.05%)
Mutual labels:  aes, aes-encryption
CryptoKnight
CryptoKnight is a general purpose cryptography desktop app
Stars: ✭ 18 (-89.94%)
Mutual labels:  aes, aes-encryption
abrute
Multi-threaded AES Brute Force File Decryption
Stars: ✭ 22 (-87.71%)
Mutual labels:  aes, aes-encryption
Qt Aes
Native Qt AES encryption class
Stars: ✭ 207 (+15.64%)
Mutual labels:  aes, aes-encryption
EncrypC
🔑 File Encryption Application using Python.
Stars: ✭ 14 (-92.18%)
Mutual labels:  aes, aes-encryption
AESCipher-Java
AES encryption working between Objective-C and Java.
Stars: ✭ 88 (-50.84%)
Mutual labels:  aes, aes-encryption
openssl
A functions wrapping of OpenSSL library for symmetric and asymmetric encryption and decryption.
Stars: ✭ 199 (+11.17%)
Mutual labels:  aes, aes-encryption
Link Lock
Password-protect URLs using AES in the browser; create hidden bookmarks without a browser extension
Stars: ✭ 418 (+133.52%)
Mutual labels:  aes, aes-encryption
Python-File-Encryptor
Encrypt and Decrypt files using Python (AES CBC MODE)
Stars: ✭ 51 (-71.51%)
Mutual labels:  aes, aes-encryption
Gonnacry
A Linux Ransomware
Stars: ✭ 341 (+90.5%)
Mutual labels:  aes, aes-encryption
Hat.sh
encrypt and decrypt files in your browser. Fast, Secure client-side File Encryption and Decryption using the web crypto api
Stars: ✭ 886 (+394.97%)
Mutual labels:  aes, aes-encryption
Persistencekit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code!
Stars: ✭ 121 (-32.4%)
Mutual labels:  userdefaults
Encryption Algorithm
DES、AES、Present、Extended Euclidean Algorithm、Miller-Rabin( 常用密码学算法)推荐书籍《现代密码学趣味之旅》---彭长根
Stars: ✭ 140 (-21.79%)
Mutual labels:  aes
Py7zr
7zip in python3 with ZStandard, PPMd, LZMA2, LZMA1, Delta, BCJ, BZip2, and Deflate compressions, and AES encryption.
Stars: ✭ 110 (-38.55%)
Mutual labels:  aes
Bouncer
Bouncer is a network TCP port redirector/forward proxy (like rinetd) with extra features like Reverse tunneling (like ssh -R), SSL tunneling (like stunnel), connection Failover, LoadBalancing and Clustering. In pure Java (BIO)
Stars: ✭ 103 (-42.46%)
Mutual labels:  aes
Persistentstorageserializable
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk.
Stars: ✭ 162 (-9.5%)
Mutual labels:  userdefaults

SecureDefaults for iOS, macOS

Build Status Platform Version Carthage compatible Swift Package Manager compatible License

RequirementsUsageInstallationContributingAcknowledgmentsContributingAuthorLicense

SecureDefaults is a wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer (key size has 256-bit length). It encludes:

  • AES-256 encryption
  • Password stretching with PBKDF2
  • Encrypt-then-hash HMAC
  • Password salting
  • Random IV

The design and strength of all key lengths of the AES algorithm (i.e., 128, 192 and 256) are sufficient to protect classified information up to the SECRET level. TOP SECRET information will require use of either the 192 or 256 key lengths. The implementation of AES in products intended to protect national security systems and/or information must be reviewed and certified by NSA prior to their acquisition and use. [1]

Motivation

  • Avoiding the following behavior https://stackoverflow.com/questions/4747404/delete-keychain-items-when-an-app-is-uninstalled. (Yes, there is still a key, but there is no data)
  • Avoiding additional thinking about there is a good place to store a particular value. (choice between Keychain and UserDefaults)
  • Improving a situation with security on the iOS platform. Many apps I've seen didn't use Keychain. They store all sensitive data in UserDefaults (access tokens, passwords, etc)... At least, this can help to make such apps a bit more secured without pain. Perhaps, if this framework is almost the same as UserDefaults, maybe developers will start using it?
  • It doesn't look good to keep many simple keys in Keychain.

Requirements

  • iOS 8.0+
  • macOS 10.11+
  • Xcode 10.1+
  • Swift 4.2+

Usage

It is pretty simple to use SecureDefaults instead of UserDefaults/NSUserDefaults. In most cases, it is the same thing that is UserDefaults. You just need to set a password to make it work.

Replace the following code:

UserDefaults.standard

by this one:

let defaults = SecureDefaults.shared
// Ensures that a password was not set before. Otherwise, if 
// you set a password one more time, it will re-generate a key. 
// That means that we lose old data as well.
if !defaults.isKeyCreated {
    defaults.password = NSUUID().uuidString // Or any password you wish
}

To use the app and keychain groups:

let defaults = SecureDefaults(suitName: "app.group") // Set a shared app group
defaults.keychainAccessGroup = "keychain.group" // Set a shrared keychain group 
if !defaults.isKeyCreated {
    defaults.password = NSUUID().uuidString // Or any password you wish
}

SecureDefaults is not able to catch that any particular data is encrypted, to obtain a raw value, use the following method:

public func rawObject(forKey defaultName: String) -> Any?

Installation

CocoaPods

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

pod 'SecureDefaults', '1.0.5' # Swift 5.0
pod 'SecureDefaults', '1.0.0' # Swift 4.2

Carthage

Add this to Cartfile

github "vpeschenkov/SecureDefaults" == 1.0.5 # Swift 5.0
github "vpeschenkov/SecureDefaults" == 1.0.0 # Swift 4.2
$ carthage update

Swift Package Manager

Create a Package.swift file.

// swift-tools-version:4.2

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(url: "https://github.com/vpeschenkov/SecureDefaults", "1.0.4")
  ],
  targets: [
    .target(name: "YourProject", dependencies: ["SecureDefaults"])
  ]
)
$ swift build

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgments

A big thanks to the following individuals:

Author

Victor Peschenkov, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].