In today's society digital communication is ever increasing and most people feel comfortable performing tasks such as managing their bank accounts, declaring their income, or exchanging other secret information using the Internet.  In order to perform such tasks while maintaining a satisfactory level of security many different security solutions, based on encryption, have been suggested.  Most such solutions involve some type of public key and private key and a user has to share his public key before a secure communication may be established with another party.  In cryptography, a key may be seen as a piece of information that determines a functional output of a cryptographic algorithm. 
It is often said that in designing security systems, it is wise to assume that the details of a cryptographic algorithm may already be available to an attacker.  This principle is known as Kerckhoffs' principle and thus it is only the secrecy of the key that provides security.  This principle is based on the fact that it is difficult to keep the details of a widely-used algorithm secret.  A key is often easier to protect, since it is often a small piece of information compared to the encryption algorithm.  However, it may also be difficult to keep the key a secret.  If the attacker obtains the key in some way he or she may recover the original message from the encrypted data. 
Encryption algorithms which use the same key for both encryption and decryption are known as symmetric encryption key algorithms.  There are also asymmetric encryption key algorithms which use a pair of keys, one to encrypt and one to decrypt.  These asymmetric encryption key algorithms allow one key to be made public while retaining the private key in only one location.  The asymmetric encryption keys are designed so that finding out the private key is extremely difficult, even if the corresponding public key is known.  A user can publish his or her public key, while keeping the private key secret, allowing anyone to send them an encrypted message. 
In order for a key to be “safe” in conjunction with symmetric encryption algorithms a length of 80 bits is generally considered the minimum and 128-bit keys are commonly used and considered to be very strong.  The keys used in public key cryptography have some mathematical structure.  For example, public keys used in the RSA system are the product of two prime numbers.  Thus public key systems require longer key lengths than symmetric systems for an equivalent level of security.  3072 bits is the suggested key length for systems based on factoring and integer discrete logarithms which aim to have security equivalent to a 128 bit symmetric cipher. 
As mentioned above it is possible to generate keys with a high degree of security, if they are long enough both for keys based on symmetric and asymmetric algorithms.  However, there may be a problem in key distribution.  If, for example two parties want to communicate with each other using symmetric cryptography they first have to decide what key to use and then safely distribute it from one party to the other.  Furthermore, the key has to be kept secret by both parties.  The risk that an intruder may find out the key increases with the time the key is in use.  Therefore, a key is normally valid only during a limited time, for example six or twelve months.  After this time a new key has to be distributed. 
Also, the distribution of keys for asymmetric cryptography encryption encounters problems with key distribution when two parties want to communicate with each other.  In order to send information in both directions they generally need to exchange public keys with each other.  Also in this case the keys usually have a limited time period during which they are valid.  For a party that communicates with many different parties the management and distribution of valid public keys may be annoying.  A typical example is when the validity of a key has expired when you need to send some secret information urgently to another party or that you have not yet exchanged public keys. 
One solution is provided in WO 2011/002412 which discloses a method for generating an encryption/decryption key, and especially for generating a one-time encryption/decryption key used for symmetric encryption, i.e. where the same key is used both for encryption and decryption.  In order to start key generation, a first terminal (A) sends a request to a central server (2) for setting up communication with a second terminal (B).  The central server (2) sends a key generating file to both terminals (i.e. terminals A and B).  Each terminal generates a different intermediate data set, i.e. a first and second data set.  The first data set generated by the first terminal (A) is sent to the second terminal (B), which generates, based on this data set, a third data set which is sent back to the first terminal.  The generation of a first cryptographic key in terminal (A) is based on a bit by bit comparison between the third and the first intermediate data set and the generation of a second cryptographic key is based on a bit by bit comparison between the first and the second intermediate data set.  The first and second cryptographic keys are the same. 
Although this manner has many advantages, it may offer challenges when implemented in systems having firewalls or other similar security measures.  Given the above mentioned challenges the inventors have realized that there is a need for a method with which it is possible for two parties to communicate in a secure way with each other without necessarily having to exchange keys with each other beforehand and which may be used in systems employing firewalls or other similar security measures. 
Accordingly, there is thus a need for improved handling of the encryption keys.