I'm currently working on a project that needs be as secure as possible key-management. My experience with encryption, decryption and key-management are none whatsoever so i did some research on the subject at hand, but im still not sure what i have thought have is safe therefore my questions:


The project in short: A client application that sends(via WIFI) sensitive credit-card data towards a local server which sends the data to a credit-card processor. The communication between the client and the local server needs to be secure at all times and i don't want to rely on settings of the server or router thus i initiate my secure communication.

client application <-> [local server -> PA-DSS Compliance Payment Application] <-> Processor

(I know that for credit-card payments there are requirements given out by the PCI-SSC specifically PA-DSS and i already have read those carefully but i'm not a expert.)


  1. (Looking at the "Client-Server Setup" below) Is this a correct implementation of a hybrid key-management approach?
  2. To ensure that the contents of the messages are valid should i add a checksum or hash in the encrypted data?
  3. The first AES256 key that both client and server have are embedded in code, because this is only needed for first contact would losing this key mean insecurity for the whole system? (i think not but i'm not sure)
  4. Should i ensure more authentication if yes then how would i achieve this?

As key-management i choose a hybrid key-management system using both AES-256 and RSA-1024/2048.

Client-Server Setup

  • [BOTH] client and server have the same AES-256 Key
  • [CLIENT] generates a private/public 1024 or 2048 key pair
  • [CLIENT] sends the public key (PEM x509 format) encrypted (CBC - PKCS7 padded) under the shared AES256-key towards the server
  • [SERVER] decrypts the received data and retrieves the public key
  • [SERVER] generates a new random AES-256 key and encrypts with the public key (O-AEP padded)
  • [SERVER] returns the AES-256 key encrypted with the public key
  • [CLIENT] decrypts the received data and retrieves the new AES-256 key
  • [BOTH] further communication is encrypted with the new AES-256 key

Thank you in advance

  • 1
    One of the points of using public/private keys is that you don't need to worry about encrypting the public key. Having a shared secret AES key to encrypt this part would be pointless. Otherwise your system looks like a common key exchange system such as SSL. Is there a reason why you're rolling your own? Adding that to the question may fend off some 'just use <blah>' answers.
    – webtoe
    Apr 3, 2012 at 10:48
  • I will use the shared secret AES key for authentication so it will have a use in the process. The reason why i'm rolling on my own is because the client-server setup is offline.
    – JustinV
    Apr 3, 2012 at 11:09

1 Answer 1


This feel like re-inventing the wheel. Big time. SSL should be able to fulfill the requirements (of PCI and many other secure communications needs), maintain both confidentiality and integrity + support good solid authentication quite simply and effectively without having to invent your own protocol.

  • I could always use SSL between the client and server (i had thought about that), but if something went wrong with the certificates or a setup is done wrong i can not guarantee that the communication is secure.
    – JustinV
    Apr 3, 2012 at 14:19
  • 2
    same goes if there's a bug in your code or a key is not loaded properly etc. Much easier to fix a broken certificate with a standard client/server software stack than bespoke home-brewed code.
    – Yoav Aner
    Apr 3, 2012 at 14:26
  • 1
    If you are worried about something going wrong in the implementation. You ABSOLUTELY should not be trying to develop an application like this from scratch. Why does EAP not work for you?
    – M15K
    Apr 3, 2012 at 14:27
  • 3
    I also have SSL working with lots of different apps. At least with SSL I know that many people much more clever than me validated its security. Hope you have the same level of confidence in your own solution.
    – Yoav Aner
    Apr 3, 2012 at 14:42
  • 1
    Using standard crypto libraries is a step in the right direction, but still doesn't give you much assurance for security. It seems like you're effectively re-inventing a key exchange protocol. This stuff is best left to the experts.
    – Yoav Aner
    Apr 3, 2012 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .