elective-stereophonic
elective-stereophonic
Encrypted Messages  
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.2

Pages: 1 ... 12 13 [14]  All

Author Topic: Encrypted Messages  (Read 56381 times)

Eadeqa

  • Hero Member
  • *****
  • Karma: +83/-68
  • Offline Offline
  • Posts: 1888
    • View Profile
Re: Encrypted Messages
« Reply #260 on: April 22, 2014, 09:31:23 am »

Will the AES encryption algo in Nxt core be able to encrypt/decrypt images?

I will add another question: what's the max size for a message? That should tell us the max possible size (megapixels) for the image.

I am sure it's possible, at least it could be possible with binary to text encoding, http://en.wikipedia.org/wiki/MIME

even if there is no "official" support.
« Last Edit: April 22, 2014, 09:33:57 am by Eadeqa »
Logged
NXT-GZYP-FMRT-FQ9K-3YQGS

landomata

  • Hero Member
  • *****
  • Karma: +121/-26
  • Offline Offline
  • Posts: 1535
    • View Profile
    • Newbium
Re: Encrypted Messages
« Reply #261 on: April 22, 2014, 09:37:53 am »


I will add another question: what's the max size for a message? That should tell us the max possible size (megapixels) for the image.



Actually we are planning to send/store the messages off-chain.

Image size limit 4 MB

« Last Edit: April 22, 2014, 09:41:27 am by landomata »
Logged

Eadeqa

  • Hero Member
  • *****
  • Karma: +83/-68
  • Offline Offline
  • Posts: 1888
    • View Profile
Re: Encrypted Messages
« Reply #262 on: April 22, 2014, 09:49:17 am »


I will add another question: what's the max size for a message? That should tell us the max possible size (megapixels) for the image.



Actually we are planning to send/store the messages off-chain.

Image size limit 4 MB

In that case, just implement your own AES encryption. It shouldn't really be hard.

Is your app written in java? javascript?

 

Logged
NXT-GZYP-FMRT-FQ9K-3YQGS

landomata

  • Hero Member
  • *****
  • Karma: +121/-26
  • Offline Offline
  • Posts: 1535
    • View Profile
    • Newbium
Re: Encrypted Messages
« Reply #263 on: April 22, 2014, 09:53:22 am »


I will add another question: what's the max size for a message? That should tell us the max possible size (megapixels) for the image.



Actually we are planning to send/store the messages off-chain.

Image size limit 4 MB

In that case, just implement your own AES encryption. It shouldn't really be hard.

Is your app written in java? javascript?

Yes will look at something separately for the images.

Android is in Java.

Eadeqa

  • Hero Member
  • *****
  • Karma: +83/-68
  • Offline Offline
  • Posts: 1888
    • View Profile
Re: Encrypted Messages
« Reply #264 on: April 22, 2014, 09:59:13 am »


I will add another question: what's the max size for a message? That should tell us the max possible size (megapixels) for the image.



Actually we are planning to send/store the messages off-chain.

Image size limit 4 MB

In that case, just implement your own AES encryption. It shouldn't really be hard.

Is your app written in java? javascript?

Yes will look at something separately for the images.

Android is in Java.

I thought so. I was confused as you you sent me a PM to javascript AES library

Java standard library includes AES ((javax.crypto.* )

You can just copy and paste and it will work just fine

-------------

I lied ... I got one more post on this issue (for inclusion in nxt.crypto.Crypto):

Code: (Java) [Select]
public static byte[] aesEncrypt(byte[] plaintext, byte[] myPrivateKey, byte[] theirPublicKey)
    throws GeneralSecurityException, IOException
{
    byte[] dhSharedSecret = new byte[32];
    Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
    byte[] key = sha256().digest(dhSharedSecret);
    SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
    byte[] iv = new byte[16];
    secureRandom.get().nextBytes(iv);
    IvParameterSpec ivSpec = new IvParameterSpec(iv);
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
    ByteArrayOutputStream ciphertextOut = new ByteArrayOutputStream();
    ciphertextOut.write(iv);
    ciphertextOut.write(cipher.doFinal(plaintext));
    return ciphertextOut.toByteArray();
}

Code: (Java) [Select]
public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] myPrivateKey, byte theirPublicKey[])
    throws GeneralSecurityException
{
    if ( ivCiphertext.length < 16 || ivCiphertext.length % 16 != 0 ) {
        throw new GeneralSecurityException("invalid ciphertext");
    }
    byte[] iv = Arrays.copyOfRange(ivCiphertext, 0, 16);
    byte[] ciphertext = Arrays.copyOfRange(ivCiphertext, 16, ivCiphertext.length);
    byte[] dhSharedSecret = new byte[32];
    Curve25519.curve(dhSharedSecret, myPrivateKey, theirPublicKey);
    byte[] key = sha256().digest(dhSharedSecret);
    SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
    IvParameterSpec ivSpec = new IvParameterSpec(iv);
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
    return cipher.doFinal(ciphertext);
}




Logged
NXT-GZYP-FMRT-FQ9K-3YQGS

verymuchso

  • Hero Member
  • *****
  • Karma: +118/-2
  • Offline Offline
  • Posts: 549
    • View Profile
    • HEAT Ledger
Re: Encrypted Messages
« Reply #265 on: April 29, 2014, 06:57:38 am »

Offspring 0.4.2e now supports AES 256 encrypted messages (while still being compatible with older XOR encrypted messages).
I'm using the bouncycastle libs to get around the 128 bit limit in the JRE.

Implementation; https://github.com/incentivetoken/offspring/blob/develop-nqt/com.dgex.offspring.ui/src/com/dgex/offspring/ui/messaging/MessageCrypto.java

This is an experimental release so things can still change, if you see a problem please post that here.
Logged
HEAT: DEX | SDK | HOME
Pages: 1 ... 12 13 [14]  All
 

elective-stereophonic
elective-stereophonic
assembly
assembly