• 0

help with DES and AES


Question

hi I have posted something like this before but I am still tackling the problem....

I am trying to encrypt bytes and then add a second encryption then remove the first without removing the second.... I have my reasons for this I need help with this not an alternative....

the encryption can be alternative so DES + DES or AES + DES or AES + AES or anything thing else but it has to be like this ... here is my code so far .... I have got the encryption layers on ... its just getting them off im struggling with (one page test code)....im getting (given final block is not correctly padded)


import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

public class ObjectCrypter {

public static void main(String[] argv) {

try {

String str = "moo";

byte[] byted = str.getBytes();

Cipher desCipher;
Cipher enCipher;

KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
SecretKey myDesKey = keygenerator.generateKey();

desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");

desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
byte[] textEd = desCipher.doFinal(byted);

System.out.println("DES?" + new String(textEd));



byte[] byt = textEd;

KeyGenerator keygenerat = KeyGenerator.getInstance("AES");
SecretKey myD = keygenerat.generateKey();

enCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

enCipher.init(Cipher.ENCRYPT_MODE, myD);
byte[] tex = enCipher.doFinal(byt);

System.out.println("AES?" + new String(tex));

desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[] textDecrypted = desCipher.doFinal(tex);

System.out.println("it work?" + new String(textDecrypted));





}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BadPaddingException e){
e.printStackTrace();
}
}

}
[/CODE]

if you can help it would be great :)

Link to comment
https://www.neowin.net/forum/topic/1120844-help-with-des-and-aes/
Share on other sites

Recommended Posts

  • 0

I'm not sure how this could work, by encrypting it with AES you can't then decrypt it with DES, as it's not in the format the DES algorithm is capable of decrypting.

It's like doing ROT13 then Base64 encoding it, then doing ROT13 again without decoding from Base64, it won't give the intended results.

  • 0

So it looks like you encrypted with DES followed by AES. Shouldn't you decrypt with AES followed by DES?

I'm not sure how this could work, by encrypting it with AES you can't then decrypt it with DES, as it's not in the format the DES algorithm is capable of decrypting.

It's like doing ROT13 then Base64 encoding it, then doing ROT13 again without decoding from Base64, it won't give the intended results.

even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

  • 0
even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

That's completely illogical and will never work. You always have to decrypt in the opposite order of encryption.

  • 0

That's completely illogical and will never work. You always have to decrypt in the opposite order of encryption.

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

  • 0

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

Use asymmetric encryption. A popular asymmetric encryption protocol is SSH. The JsCH library seems like a popular Java implementation of SSH.
  • 0

Dude what!

This and your other thread added together... Either you are NOT meant to be a programmer or you've currently got no clue how to be a programmer.

Write down your ideas and think if they're possible or not and try to plot how they would work.

Other thread: I want to make my program impossible for others to decode -> to run on a PC, it needs to be readable by a PC -> by being readable by a PC that also means people can 'read' it -> if I obscure the code will it help? And what downsides will doing that have, will it create bugs or slow down the running of my program and how much, and what will it cost to implement?

This thread: I want to make a secure chat program -> what encrytion will I use? -> What encryption types will I use? -> I do not want to use the same key to encrypt is so I will use asymmetrical encryption.

Etc. otherwise you will unfortunately keep making junk and be a pretty awful programmer.

EDIT: also reguarding SSH, it's a protocol not an encryption standard :p SSH can use various but you'd probably want to look up PGP, RSA etc.

  • 0

... that's why I said it's a protocol. Btw I don't think your ridiculing of the OP is a productive way of helping him.

I'm not ridiculing him, if you walk into your job as project manager of something with no plan, not only will your project never exist, you'll be fired.

Programming is no different.

If you just think 'yeh I`ll do this but no idea how or if its even possible' then you will never do that.

  • 0

Dude what!

This and your other thread added together... Either you are NOT meant to be a programmer or you've currently got no clue how to be a programmer.

Write down your ideas and think if they're possible or not and try to plot how they would work.

Other thread: I want to make my program impossible for others to decode -> to run on a PC, it needs to be readable by a PC -> by being readable by a PC that also means people can 'read' it -> if I obscure the code will it help? And what downsides will doing that have, will it create bugs or slow down the running of my program and how much, and what will it cost to implement?

This thread: I want to make a secure chat program -> what encrytion will I use? -> What encryption types will I use? -> I do not want to use the same key to encrypt is so I will use asymmetrical encryption.

Etc. otherwise you will unfortunately keep making junk and be a pretty awful programmer.

EDIT: also reguarding SSH, it's a protocol not an encryption standard :p SSH can use various but you'd probably want to look up PGP, RSA etc.

actually .... I get As in all my programming exams and assignments..... there are just some things I have yet to do .... I have moved on to network programming .... please do not underestimate me.... I dislike you **** OFF

I'm not ridiculing him, if you walk into your job as project manager of something with no plan, not only will your project never exist, you'll be fired.

Programming is no different.

If you just think 'yeh I`ll do this but no idea how or if its even possible' then you will never do that.

you are you are taking the ****... im asking questions to help me understand .... I find programming easy but guess what I have to learn it in specific ways I understand .... not everyone speaks english the same just like not everyone programs the same now go annoy someone else troll

Use asymmetric encryption. A popular asymmetric encryption protocol is SSH. The JsCH library seems like a popular Java implementation of SSH.

thank you for your tips /i will have a look I understand that SSH is a secure protocol used for things such as VPNs and i am feeling it is a good idea to try and use that protocol...

  • 0

See you're saying to use the SSH protocol... You wouldn't use the SSH protocol unless you're communicating with an SSH server or making an SSH client.

All I'm saying is take a step back from what you're doing and look at the overall picture.

I'm not trolling, if anyone's trolling it's you 'how do i hide my code'.

SMH, welcome to the real world.

  • 0

See you're saying to use the SSH protocol... You wouldn't use the SSH protocol unless you're communicating with an SSH server or making an SSH client.

All I'm saying is take a step back from what you're doing and look at the overall picture.

I'm not trolling, if anyone's trolling it's you 'how do i hide my code'.

SMH, welcome to the real world.

Why can't a chat client and server communicate over SSH? SSH is (among other things) a protocol for secure data communication. There are no set limitations on what that data has to be.

  • 0

As far as I'm aware SSH is a tunneling communications protocol from an SSH client to an SSH daemon (running on a *nix system) which uses public and private RSA and ESSID keys to encrypt and decrypt the data sent to and from it, so if you were to use ssh then you'd ssh to a ssh server and run a program on it... The hassle of doing all that I can't see being worth it when you can just setup PGP easily, send over the public key and just use PGP or RSA.

  • 0

While you could make a chat client run over SSH, it's not a good "fit". Something like TLS is a much better option (You aren't dealing with SSH semantics then, it's just something that encrypts and decrypts incoming and outgoing communication)

  • 0

well then maybe you can help me..... I need to create a p2p chat system with encryption.... BUT the encryption key obviously cant be in the source code or sent over the internet in plain text ..... any helps ?

You need to step away from the code, and properly think about how the overall design will work.

Are you producing a client for existing protocols?

I get that this is probably just a personal programming exercise, but are you creating client software that is based on one or more existing chat protocols and infrastructures, and just throws encryption on top? Or are you creating entirely your own thing? I'm going to assume the latter!

So, will there be a web service?

How will users discover each other? How will they know when each other is online? And what about authentication?

While it would be possible to completely avoid having a web service (and maybe that's what you actually meant by 'p2p'), it would be a pain to use:

  • To connect to each other, users would have to communicate their IP address and port number to each other through some other means, and then enter this information into their chat clients.
  • Some people have dynamic IP addresses, and additionally the port number may not be fixed, so recording this information in a 'friends list' would be useless and therefore knowing whether each other is online without separately speaking to each other would be impossible.
  • If a user's IP address is dynamic and changes part way through a chat, their new IP address is going to have to be provided to the other user all over again, and a portion of the chat may have been lost in the interruption.
  • NAT could complicate things even more.

A third-party dynamic DNS service could perhaps make some of this easier, but adds problems of its own, and there's a better option - a centralised web service.

A centralised web service will allow users to connect to one another in a simple and clean manner.

  • Users will create a unique alias on the web service and then enter it into their client. The client software can automatically talk to the web service to provide/update the IP address and port number to associate with it.
  • Periodic checks by the service, or "check ins" generated by the client, are done to keep track of the user's connection status.
  • Tying a password to the alias prevents identity theft / impersonation.
  • One user would still need to disclose a piece of information (their alias) to the other user in order to create the initial connection, but there's no getting around that. Thankfully this way is much better than above though, and with a connection established, the users can be recorded in each other's 'friends list' and they never have to supply it again. If you think your users would accept it, you could even offer an email search/lookup facility, with a friend request mechanism.

A couple of notes:

  • In storing a friend list, the unique ID (aka UID, normally a number) should be recorded (hidden), not the alias, to allow users to change their aliases without breaking friend list entries.
  • If one user decides to remove someone from their friend list, you may want to consider automatically removing them from the other person's too.

So how to go about encrypting chat then?

As already pointed out by others, asymmetric encryption is the best way of implementing this, and I hope and assume that you're already familiar with it. We need to think about some specifics though!

One thing that may influence how you implement encryption will be legislation (if we're pretending that you were developing a real product here). Your government may not actually allow you to produce an encrypted chat mechanism with no means what-so-ever of allowing them to snoop on it. Let's pretend that there would be no such restrictions though.

One simple way of implementing asymmetric encryption could be by using an encryption key belonging to the web service as a 'legitimate' middle man, and dynamically creating client certificates on the fly. A copy of the web service's public key could be embedded in the client application (preventing a third-party middle man attack in transmitting it). When connecting to the service, the client creates a new certificate, encrypts the public key with the web service public key, and sends it to the web service, which then sends back an encrypted confirmation. In transmitting a message to the other user, the client encrypts it and sends it to the web service in the same way. The web service decrypts it, re-encrypts it with the public key for the other user, and sends it on.

There are two huge problems here though:

  • The huge load placed on the web service. This could very easily be solved by only using the above mechanism to transfer the user's public keys securely to each other, then they can send encrypted communications between themselves, but does not solve the next problem below.
  • The web service is a huge weak spot. Administrators of the web service can snoop at any time they like. The government can demand to be provided access to be able to snoop. If someone should hack the web service, they can snoop.

This kind of problem exists in a lot of systems out there. Drop box for instance, there's nothing really stopping administrators accessing your data unless you pre-encrypt it, which is a pain. HTTPS is a complete joke, and so therefore is S/MIME which afaik is based on it. There are a couple of excellent solutions though that we could derive inspiration from:

  • One is spideroak, a competitor to dropbox (no, before you ask, I don't work for them). Spideroak encrypts all of your data, and keep a copy of the encryption key, but they never keep a copy of the password for the encryption key. If you loose your password, you loose your data. As long as they are true to their word, and the software really operates as they say it does, never sending your password to them or anyone else, your data is completely secure.
  • PGP based email encryption. This is asymmetric encryption. Each user generates a key pair. They send a copy of their public keys to each other, and verify them (to ensure no-one has intercepted them and performed a switch) through another form of communication. This is completely secure as long as correct verification is done, and they keep their private keys secure.

We could improve the security of our chat application by copying PGP. (I think there's actually an existing plugin for Pidgin that does this). The client allows the user to generate a key pair, and the public key could automatically be sent to anyone you connect to. You use another means such as the phone to verify them, and you're secure. Public keys could also be stored in friend lists, and signed by the user, in order to record the fact that they have verified and can trust that key, so you don't need to verify it every time, and so that if the developer of the client (you) tried to switch the key to snoop, they'd notice. Users would still need to trust that the client application isn't leaking unencrypted chat content or their private keys back to the developer (you) or government, but it wouldn't be too difficult for an expert to analyse the binary of your application and the web traffic it generates in order to determine if anything fishy is going on. (It would not be possible to analyse the web service described earlier is this way, an analyst would have to be granted special access to it, and you could easily hide things or change them at any time you liked).

The design outlined is not necessarily perfect however, because the user's key is stored locally on their computer. If they want to use a different computer, or loose their computer for any reason, that's a problem for most users. It would probably be better if user encryption keys (public and private) were stored on the web service. The public key could be stored as is, just like a public public-key server, and record signatures placed on keys, allowing groups of friends to more easily establish trust within their group with fewer external verification checks needed. The private keys would be encrypted with the user's password, and the password would never itself be stored by the web service, just like spideroak. When the user logs in to their chat client, a mechanism is gone through to that authenticates the user, crucially without their password being submitted to the web service, and hopefully without unnecessarily handing out a copy of the private key to anyone without the correct password. This sounds difficult if not impossible but spideroak apparently manages to do exactly this! Additionaly the transfer of the private key once the user is authenticated must be done securely, perhaps the copy of the already encrypted copy could be sent, and then decrypted with the password in the client...but then why wouldn't spideroak simply do that...I think I need to get some sleep at this point, and think this bit through some other time...

One potential problem with this improved mechanism though is that for security, users cannot log in to the website (pretending one existed for the product), if logging in to it was needed for some particular functionality, without compromising their security. Spideroak strongly advise against logging in to the website, instead doing everything within, or establishing an authenticated web session through, their application.

I'm probably going way beyond what you perhaps wanted with this, but it was interesting to think about :p

What about saved chats?

This can wait for another time, It's really late now and I should get some sleep...!

-----

edit: fixed a few minor typos and a broken link

  • Like 2
  • 0

You need to step away from the code, and properly think about how the overall design will work.

Are you producing a client for existing protocols?

I get that this is probably just a personal programming exercise, but are you creating client software that is based on one or more existing chat protocols and infrastructures, and just throws encryption on top? Or are you creating entirely your own thing? I'm going to assume the latter!

So, will there be a web service?

How will users discover each other? How will they know when each other is online? And what about authentication?

While it would be possible to completely avoid having a web service (and maybe that's what you actually meant by 'p2p'), it would be a pain to use:

  • To connect to each other, users would have to communicate their IP address and port number to each other through some other means, and then enter this information into their chat clients.
  • Some people have dynamic IP addresses, and additionally the port number may not be fixed, so recording this information in a 'friends list' would be useless and therefore knowing whether each other is online without separately speaking to each other would be impossible.
  • If a user's IP address is dynamic and changes part way through a chat, their new IP address is going to have to be provided to the other user all over again, and a portion of the chat may have been lost in the interruption.
  • NAT could complicate things even more.

A third-party dynamic DNS service could perhaps make some of this easier, but adds problems of its own, and there's a better option - a centralised web service.

A centralised web service will allow users to connect to one another in a simple and clean manner.

  • Users will create a unique alias on the web service and then enter it into their client. The client software can automatically talk to the web service to provide/update the IP address and port number to associate with it.
  • Periodic checks by the service, or "check ins" generated by the client, are done to keep track of the user's connection status.
  • Tying a password to the alias prevents identity theft / impersonation.
  • One user would still need to disclose a piece of information (their alias) to the other user in order to create the initial connection, but there's no getting around that. Thankfully this way is much better than above though, and with a connection established, the users can be recorded in each other's 'friends list' and they never have to supply it again. If you think your users would accept it, you could even offer an email search/lookup facility, with a friend request mechanism.

A couple of notes:

  • In storing a friend list, the unique ID (aka UID, normally a number) should be recorded (hidden), not the alias, to allow users to change their aliases without breaking friend list entries.
  • If one user decides to remove someone from their friend list, you may want to consider automatically removing them from the other person's too.

So how to go about encrypting chat then?

As already pointed out by others, asymmetric encryption is the best way of implementing this, and I hope and assume that you're already familiar with it. We need to think about some specifics though though!

One thing that may influence how you implement encryption will be legislation (if we're pretending that you were developing a real product here). Your government may not actually allow you to produce an encrypted chat mechanism with no means what-so-ever of allowing them to snoop on it. Let's pretend that there would be no such restrictions though.

One simple way of implementing asymmetric encryption could be by using an encryption key belonging to the web service as a 'legitimate' middle man, and dynamically creating client certificates on the fly. A copy of the web service's public key could be embedded in the client application (preventing a third-party middle man attack in transmitting it). When connecting to the service, the client creates a new certificate, encrypts the public key with the web service public key, and sends it to the web service, which then sends back an encrypted confirmation. In transmitting a message to the other user, the client encrypts it and sends it to the web service in the same way. The web service decrypts it, re-encrypts it with the public key for the other user, and sends it on.

There are two huge problems here though:

  • The huge load placed on the web service. This could very easily be solved by only using the above mechanism to transfer the user's public keys securely to each other, then they can send encrypted communications between themselves, but does not solve the next problem below.
  • The web service is a huge weak spot. Administrators of the web service can snoop at any time they like. The government can demand to be provided access to be able to snoop. If someone should hack the web service, they can snoop.

This kind of problem exists in a lot of systems out there. Drop box for instance, there's nothing really stopping administrators accessing your data unless you pre-encrypt it, which is a pain. HTTPS is a complete joke, and so therefore is S/MIME which afaik is based on it. There are a couple of excellent solutions though that we could derive inspiration from:

  • One is spideroak, a competitor to dropbox (no, before you ask, I don't work for them). Spideroak encrypts all of your data, and keep a copy of the encryption key, but they never keep a copy of the password for the encryption key. If you loose your password, you loose your data. As long as they are true to their word, and the software really operates as they say it does, never sending your password to them or anyone else, your data is completely secure.
  • PGP based email encryption. This is asymmetric encryption. Each user generates a key pair. They send a copy of their public keys to each other, and verify them (to ensure no-one has intercepted them and performed a switch) through another form of communication. This is completely secure as long as correct verification is done, and they keep their private keys secure.

We could improve the security of our chat application by copying PGP. (I think there's actually an existing plugin for Pidgin that does this). The client allows the user to generate a key pair, and the public key could automatically be sent to anyone you connect to. You use another means such as the phone to verify them, and your secure. Public keys could also be stored in friend lists, and signed by the user, in order to record the fact that they have verified and can trust that key, so you don;t need to verify it every time, and so that if the developer of the client (you) tried to switch the key to snoop, they'd notice. Users would still need to trust that the client application isn't leaking unencrypted chat content or their private keys back to the developer (you) or government, but it wouldn't be too difficult for an expert to analyse the binary of your application and the web traffic it generates in order to determine if anything fishy is going on. (It would not be possible to analyse the web service described earlier is this way, an analyst would have to be granted special access to it, and you could easily hide things or change them at any time you liked).

The design outlined is not necessarily perfect however, because the user's key is stored locally on their computer. If they want to use a different computer, or loose their computer for any reason, that's a problem for most users. It would probably be better if user encryption keys (public and private) were stored on the web service. The public key could be stored as is, just like a public public-key server, and record signatures placed on keys, allowing groups of friends to more easily establish trust within their group with fewer external verification checks needed. The private keys would be encrypted with the user's password, and the password would never itself be stored by the web service, just like spideroak. When the user logs in to their chat client, a mechanism is gone through to that authenticates the user, crucially without their password being submitted to the web service, and hopefully without unnecessarily handing out a copy of the private key to anyone without the correct password. This sounds difficult if not impossible but spideroak https://spideroak.co...do exactly this! Additionaly the transfer of the private key once the user is authenticated must be done securely, perhaps the copy of the already encrypted copy could be sent, and then decrypted with the password in the client...but then why wouldn't spideroak simply do that...I think I need to get some sleep at this point, and think this bet through some other time...

One potential problem with this improved mechanism though is that for security, users cannot log in to the website (pretending one existed for the product), if logging in to it was needed for some particular functionality, without compromising their security. Spideroak strongly advise against logging in to the website, instead doing everything within, or establishing an authenticated web session through, their application.

I'm probably going way beyond what you perhaps wanted with this, but it was interesting to think about :p

What about saved chats?

This can wait for another time, It's really late now and I should get some sleep...!

well I will answer the first two sub titles :p the 3rd one will require more reading but I have to get my washing out before i go to class xD ......

firstly thank you for taking the time to show interest it shows you are taking me seriously...

secondly This is my aim and how I am trying to get there...

this P2P connection will have a host so far im starting off easy, the host will be decided by the people using the chat (e.g. run host.class)

the host will be listening on the desired port (default probs 4444 or 5555 something like that) the client then connects to host ... yes target will need to be specified by client (I am trying to do this with as little database work as possible but I am not closed to it )

this program is not designed for use by a large populous its a program that will be off the radar for now and used for specific private communications....

I was thinking about using private and public key methods but im not sure how they work yet....

There will be another chat I will be making in the future which will use usernames and such both with encryption and without (one is a project I have to do other is just because I want to ) ....

like I said rest will have to wait!!! also no saved chats ever ! all will be burnt ...

  • 0

even when I encrypt with DES both times i still get the same result ...the thing is im trying to set up a safe way to send information where neither party has the others keys so encryptions needs to be removed in the same order they were added .... so if i encrypt the string "moo" ... with a passkey such as "hello" then encrypt the new string with the passkey "goodbye" I then need to remove the encryption "hello" after which i then remove the passkey goodbye .... :p get it?

What you're talking about is mathematically possible, however I don't think it can be secure. The only way (that I know of) to do this is is with very simple algorithms (hence the lack of security). Take, for example the XOR bitwise operation. With a simple XOR cipher, you can encrypt a text with a key K1, and then again with a key K2. To decrypt, you can use K1 and K2 in any order.

I would, however, suggest following the lead of existing open source software that fits with your goals. Given your current knowledge, it's basically impossible to invent a novel cryptographic approach.

If I have seen further it is by standing on the shoulders of giants. --Isaac Newton

  • 0

What you're talking about is mathematically possible, however I don't think it can be secure. The only way (that I know of) to do this is is with very simple algorithms (hence the lack of security). Take, for example the XOR bitwise operation. With a simple XOR cipher, you can encrypt a text with a key K1, and then again with a key K2. To decrypt, you can use K1 and K2 in any order.

I would, however, suggest following the lead of existing open source software that fits with your goals. Given your current knowledge, it's basically impossible to invent a novel cryptographic approach.

If I have seen further it is by standing on the shoulders of giants. --Isaac Newton

ye I know it is possible I went to a seminar about this kind of stuff ... though we talked about methods and ideas they never really shared how to do it xD which is annoying so I know its possible these people are contractors for the DoD ....I am going to try public and private keys to see where that gets me though I dont want to use it without knowing exactly how the mathmatical algorithms work it seems like an odd concept ... once I read the logic behind it i will be fine ....

"with great power comes great responsibility" -- ben parker

  • 0

:woot: best post in this entire forum since a long while.

I know right someone who shows interest and posts a length post !

also question for you!

I cannot understand why this is refusing to work


KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024); //it complains about this line, "miss placed constructs, delete token 1024?
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();

[/CODE]

  • 0

package enchat;
import java.security.*;
import java.security.spec.*;
import java.io.*;
import java.math.*;
public class RSAe {

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(1024);
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();
public static void main(String[] args) {


}

}
[/CODE]

  • 0

So it's not. That line of code has to be inside a method, this is just a rule of the Java language. At the class level you can only have method or field declarations, and field declarations can optionally have an initializer. That line of code is neither.

  • 0

So it's not. That line of code has to be inside a method, this is just a rule of the Java language. At the class level you can only have method or field declarations, and field declarations can optionally have an initializer. That line of code is neither.

oooooh derp ... I did something stupid didnt I, I facepalmed when I realised I am not thinking at all .... (its been a while since i last slept)

This topic is now closed to further replies.
  • Posts

    • Russia was able to invade Crimea because of those people. But my point is that I've personally heard how great it was to be "back in Russia" right afterwards - look how great it is now. I've asked you a question in another comment which you haven't answered, so I'll ask it again: is it better now without "Europrats"?
    • ZimaBoard 2 1664 Starter Kit review: it's a cool and affordable DIY NAS by Steven Parker IceWhale Technology reached out to me asking if I was interested in testing the ZimaBoard 2, and after convincing them to send me the Starter Kit, it arrived at my doorstep in May. A bit of background: it is a Shanghai-based Chinese company founded in 2020, which specializes in single-board servers and personal cloud solutions. From searching around online, user feedback on the company and ZimaOS is mostly positive, so we're off to a good start. In addition, I should probably point out that although they do not have a large portfolio of NAS devices, with just four of what they do offer, they seem to have covered everything from a relatively low-priced entry point with the ZimaBoard 2, right up to the high end, with the ZimaCube 2 Creator Pack that even includes an NVIDIA RTX PRO 2000. Anyway, as already mentioned, what we have today is the ZimaBoard 2 Starter Kit, and here are the full specifications: ZimaBoard 2 Model 832, 1664 CPU Intel Core N150 (4x E Cores/Threads, Max burst up to 3.6 GHz) TDP: 6W (Base) 10W (Max) Graphics Intel UHD Graphics 24 EUs (1.00 GHz) Memory 8 GB, 16 GB DDR5 4800MT/s non ECC SODIMM (soldered) Disk Capacity 60 TB (30 TB x 2) Supported RAID Types TRAID, TRAID +, RAID0, RAID1, RAID5, RAID 6, RAID 10 Storage 2 x SATA 3.0 6Gb/s Ports with Power Bootloader 32 GB, 64 GB eMMC Network 2x RJ-45 2.5 GbE PCIe 1 x PCIe 3.0 (via LPC) USB Ports 2 x USB-A 3.1 (5 Gbps) Display Mini-DisplayPort 1.4 (4K@60Hz) Hardware Transcoding Engine H.264, H.265, MPEG-4, VC-1 Maximum resolution: 4K (4096 x 2160); Maximum FPS: 60 Virtualization Intel® AES New Instructions Intel® Virtualization Technology (VT-x) Intel® Virtualization Technology for Directed I/O (VT-d) Size (H/W/D) 140mm x 83mm x 31mm Weight 0.4 kg (only ZimaBoard 2 device) Power 12v 5A Power Supply Warranty 1 year (Global) 2 Years (EU) OS ZimaOS v1.6.1 MSRP $339, $399 ($548.60) As you can see above, there are two variants of the ZimaBoard 2. The lesser variant has half the eMMC storage and 8 GB less RAM, although it also costs $60 less than the top variant we are testing today. The above pricing is only for the ZimaBoard 2. I put the MSRP of the Starter Kit next to it in brackets, although as of publishing, it is discounted to $534.50. The ZimaBoard 2 started life on Kickstarter and shipped to backers in August last year. It became available via the official website in late 2025 and Q1 2026. This hobbyist NAS contains the still relatively new N150 Intel CPU released in the first quarter of 2025, with support for DisplayPort 1.4, HDMI 2.1, although in this case, the memory is integrated into the board itself, so it will not be possible to upgrade or expand the amount. It also supports AV1 decoding, as well as H.264, VP8, VP9, H.265 (8 bit), and H.265 (10 bit). The different capabilities in the Alder Lake-N (and Twin Lake) series are listed below. Processor E-cores L3-cache Turbo clock GPU GPU-clock TDP Intel N355 8 6 MB 3.9 GHz 32 EUs 1.35 GHz 9 W Intel Core 3 N350 3.9 GHz 1.35 GHz 7 W Intel Core i3-N305 3.8 GHz 1.25 GHz 9 W Intel Core i3-N300 3.8 GHz 1.25 GHz Intel N250 4 3.8 GHz 1.25 GHz 6 W Intel Processor N200 3.7 GHz 0.75 GHz Intel N150 3.6 GHz 24 EUs 1 GHz Intel N97 1.2 GHz 12 W Intel Processor N100 3.4 GHz 0.75 GHz 6 W The CPU is part of the Twin Lake series that sits near the bottom of the N-series, designed for low- powered systems and entry-level laptops, and as such has a base level TDP of just 6W. As I have noted before, we are seeing another NAS with a great amount of RAM. It's important to mention that the ZimaBoard 2's memory is integrated into the base board (which is why they have two variants of it). As a reminder, up until a couple of years ago, it was commonplace to only get 2 or 4GB max on a flagship Synology or QNAP home NAS. Ever since the likes of TerraMaster and more have entered the market with ample RAM sizes included in their NAS offerings, it has gone a long way in forcing the hands of the traditional makers to up their game a bit. First impressions The Starter Kit came in one outer box with several packages inside it (shown above). I forgot to take pics of it because when it arrived, it wasn't clear what was inside, and I had to confirm with my contact that I received the entire Starter Kit. In the box ZimaBoard 2 ZimaBoard 2 HDD Expansion Bracket + PCIe card frame Zimaboard Mini DisplayPort Male to HDMI Female Cable 4K 60Hz Zimaboard PCIe 3.0 x4 to Dual NVMe M.2 SSD Adapter Card Quick guide [full online guide] Limited warranty notice Screws Design Where to start? You'd be forgiven for mistaking it as an SSD enclosure if not for all the ports on it. It is completely made out of metal, and the top is an entire heatsink. It has a premium feel about it, but it definitely looks like a hobby device. As you will see, the completed build looks like it belongs in a server or meter closet rather than as a showpiece on someone's desk. On what I am calling the rear, there's a Mini DisplayPort (1.4), two 2.5 GbE ports, with Type A 3.1 USB ports, and then the barrel connector port. Around the front, there are two SATA6 ports with a power connector in the middle. Left side Right side One side is completely free of ports. On the other there's a slit that allows for the feed of a CPU fan cable, and a PCIe 3.0 X4 slot. Top Bottom The top is entirely made up of a heatsink except for the extended height for the I/O on the rear. Around the other side, you can find the ZIMA branding and some regulatory information stamped near the bottom. As you may see from the bottom of the ZimaBoard 2, it scratches quite easily from just moving it around on my Ikea island. Teardown Before we get started, let's have a look at this thing on the inside. The steps to get to the board are as follows: Remove the four smaller Torx screws on the bottom of the ZimaBoard 2; Remove the four larger Torx screws on the sides of the device; Carefully unstick the CMOS battery from the PCB; Remove two Phillips screws on the PCB; Lift out the PCB. Yes, as you can tell from the instructions, you need three different tools to remove Torx and Phillips screws (10 in total), and unhelpfully, one of the screws is located under the CMOS battery, which is stuck onto the PCB. Building Now comes the fun part. Because the ZimaSpace website does not provide any guidance on how to put the Starter Kit together. They only have guidance for connecting the CPU fan. However, they did upload a video to their YouTube channel that shows the entire process. To install the fan, first remove the four screws on the bottom of the ZimaBoard 2, then on the inside, there is a CPU FAN connector where you can attach the fan, reattach the ZimaBoard 2 frame, and feed the fan cable through the provided slit. Then remove the nearest screw on the side and attach the fan frame to the side of the device using the same screw. ZimaBard 2 screws Aligning the screws Bottom view Remember those four screws we removed to access the CPU FAN? Longer screws are provided in the box with the HDD Expansion Bracket, which is what you will now need to attach the ZimaBoard 2 to it. Helpfully, the orientation on how to attach it is made obvious when the frame can only be screwed on at the same overall length as the ZimaBoard 2. If you do it the wrong way around (which is what I did initially) one side hangs off the frame, and it becomes difficult to attach the PCIe Adapter Card cable. PCIe card frame Other side PCIe slot connector Next, it's time to attach the PCIe card frame, which is fastened with the help of 3.5-inch SATA HDD (3 screws). These are toolless screws that you can just use your fingers to fasten them with. Then it is time to connect the provided PCIe cable with the slot connector on one side of the ZimaBoard 2, feed it through the bottom of the HDD frame, and fasten it with two standoffs. Both bracket options 2280 standoffs with 2x 4TB MP44Q The PCIe 3.0 X4 card comes with a short bracket option, handy if you decide to place it inside a different NAS or rack server, but here we need the long bracket. Oddly enough, the M.2 standoffs were preinstalled into the 22110 position, but extra standoffs are included in the box, which I installed at the 2280 position for our use. I added a couple of MP44Q M.2 PCIe 4.0 SSDs (2 x 4TB) that can be availed on Amazon for $478.99 (the lowest price for 3 months) that TEAMGROUP supplied us with Then we have the almost completed build, you just need to push the card into the PCIe slot. Unfortunately, IceWhale Technologies did not provide a screw for the PCIe card frame (this is also apparent in their own video). Here it is at several different angles, with the last pic showing the SATA Y-Cable connected to the two WD Red Plus 4TB drives. Setup and Usage Next, you connect your cables to the I/O, and the ZimaBoard 2 powers on automatically, as there is no power button on the device. Power is controlled through the Settings in ZimaOS. BIOS The ZimaBoard 2 includes an Aptio BIOS from American Megatrends [1, 2, 3], and you can setup pretty much everything here including the boot order, which is locked to the UEFI OS, however above that choice you can enable or disable booting to a SATA/USB bootloader so this would still allow you to switch to an alternative bootloader and boot from it, or disable it to instead always start from the first disk with an OS installed on it. Initial Setup Upon connecting to the LAN and booting up, the ZimaBoard 2 can be reached by navigating to the IP address (shown if you have a monitor connected), or you can find it using the ZIMA Client desktop application, which is essentially a Zima device finder. Initializing the ZimaBoard 2 The ZimaOS setup process is pretty straightforward, through a wizard, and in full above, it basically consists of setting up an account and some handy tips, and that's that! Post Setup (ZimaOS update) Upon first boot, you are alerted that there is a ZimaOS update from 1.5.0 to 1.6.1, which I applied; the full process is shown above with the changelog. ZimaBoard 2 Storage Setup Next, it is time to set up the storage. ZimaOS actually throws everything onto the eMMC flash drive; it is also the default location of AppData, which is definitely something to be wary about, as the 45GB available storage could fill up quickly. HDDs I first attempted to create a Storage Pool using the two 4TB WD Red Plus NAS drives, and got an error message: After several attempts and then looking online, I discovered it was a bug with ZimaOS where the fix was simply to reboot ZimaOS and then try again, this time I was able to create a RAID mirror using the two drives. SSDs I did the same for the SSDs, as you will see in the above gallery, when I created the second Storage Pool, it only allowed me to select available drives. ZimaBoard 2 AppData ZimaOS comes with an App Store that includes a repository of almost 400 apps, so you will be able to find most of what you'll need for a NAS (although after a quick search, I wasn't able to find a Surveillance Manager), and now comes the important part: moving the default AppData location off the 45GB eMMC and onto a larger volume: Open Settings Then Apps Then, in the Select a new location field, click on the new Storage volume you want to move it to (in my case, the Apps Storage Pool), which is the SSD RAID mirror. Confirm the Migration warning Be praised! You can also do this for Docker (which by default installs onto the 45GB eMMC flash drive) and the User database. Plex Setup Next, I tested the configuration by installing the Plex Server app from the App Store. The library folders must already exist (which I placed into the Storage Pool). Plex Server setup is straightforward and requires very little configuration. In my case, all I had to do was add the media path I just created, which you can also browse to using the folder icon in the path field. In addition, you can now map the new Media library in Windows Explorer using the Zima Client. Oddly enough, it is not possible to access the ZimaBoard 2 over the Network Neighborhood; you must map drives using the client, which is shown in the last image in the above gallery. I watched one of my Blu-Ray rips, which is Dolby Vision with Dolby Atmos, and the content played fine with no stuttering or buffering, which is what anyone needs in this scenario. ZimaBoard 2 Zima Client mobile app There's also a client for mobile. It is pretty barebones, as shown in the above gallery, for example, the Apps screen launches the WebUI for that app, and the Backup must be done manually. On opening Backup, you can select internal storage folders on your phone to backup to the ZimaBoard 2's storage, and although this is constantly scanned, the backup action itself must be manually triggered. There is an option to allow foreground backup (last image in the above gallery), but this basically means the queued backup gets triggered when you manually open the app. Benchmarking SATA PCIe 3.0 X4 A CrystalDiskMark test on a mapped network drive from within a Windows 11 25H2 PC (image above) connected over a 2.5 GbE was well within acceptable ranges. Writes were generally better on the SSD RAID mirror. SATA PCIe 3.0 X1 I also ran the NAS Performance tester, which tests the link speed performance. As you can see, it pretty much maxes out the 2.5GbE connection. Of course, you can also opt to bond the two 2.5 GbE connections for a bit more umph, but I didn't do that. Thermals Top PCIe card SATA HDDs Next, I measured some hotspots while playing content on Plex. It's fair to say this will perform better than a NAS that is enclosed in a metal or plastic case, as almost everything storage-wise is exposed! Anyway, the ZimaBoard 2 did not break a sweat with Plex streaming or disk benchmarks. ZimaOS Factory Reset ZimaOS does not include a factory reset option. Instead, you have to download the ZimaOS image and flash it to the eMMC manually. The flashing process is shown in the above gallery. The steps to do so are listed below: Download the ZimaOS image here; Open BalenaEtcher (Run as Administrator) and select the image; Select your inserted USB drive (min 8 GB) Flash to it; Connect your USB drive, monitor, keyboard, USB hub (optional), mouse (optional), and network cable (recommended) to the ZimaBoard 2; Connect power and press F11 continuously; Select your USB drive starting with UEFI in the boot device menu; Press Enter on the Install ZimaOS option; Select /dev/mmcblk0 (MMC) flash drive as target; Confirm with (three times) to wipe the target disk; Wait a couple of minutes while ZimaOS installs; Remove the USB drive and confirm with a reboot; Your ZimaBoard 2 has been factory reset. However, you don't have to stick with ZimaOS, in fact the company also offers official CasaOS images, that are based on Debian; or as they say themselves, put anything you want on this "hackable single board server" it's up to you. Conclusion I had a lot of fun putting this together. I've custom-built all my own PCs and servers since the 90s, and this is the first time I have had to put a NAS together. Even if the actual base ZimaBoard 2 was already a completed build, it still feels pretty custom. I just wish that IceWhale Technology included a getting-started guide in the box for the Start Kit, which would have really completed this kit. Instead, I had to search for the official video on the YouTube channel to make sure I wasn't doing anything wrong. So who is this for? Definitely the hobbyist who is comfortable building their own PC and servers. It also has a much smaller footprint than its nearest equivalent (in terms of specs), like the Beelink Me Pro, which is another NAS I will be testing soon. Although the Beelink does not come with the PCIe 3.0 X4 expansion, the ZimaBoard 2 Starter Kit suddenly looks to be a great bargain, even if it only offers the two 3.5-inch bays over the four in the other example. It makes a lot of sense to use Intel's N150 chip inside a NAS; it is more than capable of doing what the ZimaBoard 2 is intended for, media streaming and backup. It also looks like the IceWhale Technology staff are quite active in the official forums helping people with issues they come across with ZimaOS and the devices, peer support seems to be good as well, I was quickly able to find why I was not able to create a new Storage Pool in ZimaOS v1.6.1 even though that is quite a serious bug, hopefully it will be fixed in the next update. If you are comfortable with the command line and Docker, you'll be fine. You can do great things with this hardware. This was my first time with ZimaOS. It seems a bit barebones in comparison to the likes of Synology DSM, TOS, and UGOS, but it has a ton of apps to get you started with your home or small business NAS. Where to buy As of publishing, IceWhale Technology is running a discount of up to 5% for the Starter Kit. If you opt to get just the ZimaBoard 2 itself, it does come with a SATA Y-Cable, so you will be able to connect up to two 3.5-inch HDDs to it. ZimaBoard 2 1668 Starter Kit for $534.50 on Amazon US (was $548.60) ZimaBoard 2 832 Starter Kit for $372.88 on Amazon US (was $390.60) Zimaboard 2 1668 (16GB+64GB) for $419.90 on Amazon US Zimaboard 2 832 (8GB+32GB) for $359.90 on Amazon Disclosure: IceWhale Technology provided a free sample without any editorial input or review pre-approval. Good to know The Amazon link is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, when you purchase through links on our site, we earn from qualifying purchases.
    • It's in the Insider's group so yes it's technically beta, though these days it's hard to see much of a difference unless you opt for the most extreme beta builds, which I don't. When I moved here from the Release Preview channel I did so primarily because I wanted to see how well the restored taskbar functionality (restored from Win10, and earlier) is working and whether it was time to finally abandon SAB--and it is--working fine, so far. Not as polished as SAB, but it'll do for me.
    • I've been using MWB Premium for a number of years so that along with Windows updates and updated browser should be fine. Thanks for that.
  • Recent Achievements

    • Week One Done
      flexorcist earned a badge
      Week One Done
    • One Month Later
      Woland13 earned a badge
      One Month Later
    • Week One Done
      Woland13 earned a badge
      Week One Done
    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      488
    2. 2
      +Edouard
      220
    3. 3
      PsYcHoKiLLa
      147
    4. 4
      Steven P.
      74
    5. 5
      FloatingFatMan
      70
  • Tell a friend

    Love Neowin? Tell a friend!