Skip to content

Lukasz-Bialy/AES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Encryption alghoritm:
1. Create 2048-bit private and public key (RSA.generate(String name) generates two RSA keys, as parametr it takes String for user name and uses it to name the .key files)
    1a) Private key is encrypted for storing
        1aa)RSA.SHA256(String password) creates hash using SHA1 from user password
        1ab)AES.encryptRSAPrivateKey(SecretKeySpec skspec, Key privateKey) encrypts private key using "AES/CBC/PKCS5Padding" and hash from RSA.SHA256
2. AES generates 128-bit session key with AES.generateSessionKey()
3. AES generates 128-bit initialization vector AES.randomInitVector() needed for non deterministic keys
4. AES.encrypt starts encryption
    4a) AES.encrypt() starts file encryption using "AES/" + mode + "/PKCS5Padding" and sessionKey also optionaly init vector
    4b) AES.processFile() writes byte blocks to output file in .enc format
5. Encryptor creates Header object with info about message alghoritm (keySize, blockSize, mode, format, session key, init vector)
6. Header is encrypted using RSA/ECB with padding and encrypts 256-byte blocks using every receiver public key

Session Key:
Session key is generated by KeyGenerator Class, which uses SecureRandom. SecureRandom provides cryptographically strong random number. SecureRandom must produce non-deterministic output.
Therefore any seed material passed to a SecureRandom object must be unpredictable, and all SecureRandom output sequences must be cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security.

Generated RSA(public and private) keys are stored in PrivateKeys and PublicKeys folder
Generate RSA Keys generates 2 keys Private and Public for username given in textbox (.key in src folder)



SessionKey = 128bits

RSA Keys = 2048bits


getEncoded for RSA Keys
Returns the name of the primary encoding format of this key, or null if this key does not support encoding.
The primary encoding format is named in terms of the appropriate ASN.1 data format, if an ASN.1 specification for this key exists.
For example, the name of the ASN.1 data format for public keys is SubjectPublicKeyInfo, as defined by the X.509 standard; in this case, the returned format is "X.509".
Similarly, the name of the ASN.1 data format for private keys is PrivateKeyInfo, as defined by the PKCS #8 standard; in this case, the returned format is "PKCS#8".




TODO SERVER SIDE
Add blockSize for transporting data (Header)

Releases

No releases published

Packages

No packages published