Multiple client connection to Nginx server

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple client connection to Nginx server

ASHIQUE CK
Hi,
We are using a Crypto Accelerator Engine to offload AESGCM and RSA parameters. Trying to connect multiple clients simultaneously with a single Nginx server, which is using this accelerator.  The Key and IV is passing only at handshake, and after handshake this set of key and IV is using for all encryption and decryption. So at Engine side, we are storing this Key and IV to a buffer and while encrypting/decrypting , this Key and IV is used from this buffer. But, while multiple client connects, the last saved Key/IV is getting for all clients.
        So, is there any way to get a unique ID foer each client connection ?

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

ASHIQUE CK
Hi,
Any help on this ?

On Wed, Dec 12, 2018 at 3:03 PM ASHIQUE CK <[hidden email]> wrote:
Hi,
We are using a Crypto Accelerator Engine to offload AESGCM and RSA parameters. Trying to connect multiple clients simultaneously with a single Nginx server, which is using this accelerator.  The Key and IV is passing only at handshake, and after handshake this set of key and IV is using for all encryption and decryption. So at Engine side, we are storing this Key and IV to a buffer and while encrypting/decrypting , this Key and IV is used from this buffer. But, while multiple client connects, the last saved Key/IV is getting for all clients.
        So, is there any way to get a unique ID foer each client connection ?

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

OpenSSL - User mailing list
On 12/12/2018 12:54, ASHIQUE CK wrote:

> Hi,
> Any help on this ?
>
> On Wed, Dec 12, 2018 at 3:03 PM ASHIQUE CK <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>     We are using a Crypto Accelerator Engine to offload AESGCM and RSA
>     parameters. Trying to connect multiple clients simultaneously with
>     a single Nginx server, which is using this accelerator.  The Key
>     and IV is passing only at handshake, and after handshake this set
>     of key and IV is using for all encryption and decryption. So at
>     Engine side, we are storing this Key and IV to a buffer and while
>     encrypting/decrypting , this Key and IV is used from this buffer.
>     But, while multiple client connects, the last saved Key/IV is
>     getting for all clients.
>             So, is there any way to get a unique ID foer each client
>     connection ?
>
>
The following assumes that the accelerator is accessed using an
OpenSSL "engine" plugin, if instead you are inserting code in NGINX
to hand over the complete SSL/TLS record processing to the hardware,
then a different approach is needed.

OpenSSL Crypto Engines are not limited to SSL/TLS but can be used
for other tasks using the OpenSSL libcrypto library.

Thus the way this works is that the SSL/TLS requests an EVP "handle"
for each key that it wants to use, this handle then maps (indirectly)
to a structure passed to the engine, which is unique to each key.

A correctly implemented engine is supposed to use that structure to
tell the difference between different keys stored in the actual
hardware.

For the case of GCM key/IV pairs, it may be that in some situations
OpenSSL requests more than one EVP key instance for the same key,
typically to allow each to have its own independent state (for GCM,
this is the counter, for CBC it would be the IV chaining from block
to block).  The simple solution is to just treat them as different
keys, but if this uses too many hardware key storage locations, an
engine may use some way to recognize the reused key, share the
hardware object and keep count of how many "handles" point to that
key.



Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

ASHIQUE CK
Hi,
Thanks for your reply.
Openssl only passes (ctx,type,arg,ptr) in the case of header and (ctx,out,in,inl) in the case of message, these two are the only links to engine after the handshake process for the whole process. In my case, I am downloading a file from nginx root directory using a client program. How can I get a unique id, so that I can copy the respective Key and Iv everytime when a sslwrite request comes from a client with that id. Because I am trying to run 3 clients simultaneously for downloading a file. I am able to download only at one client ,the last connected one, and other two shows that tag verification failed. Because both those connections got the same key and Iv of the last connection. 
   So for every client connection, is there any way to get a unique id so that i can load respective Key and Iv. But the only link from openssl to the engine are the above mentioned two cases. Only what I am getting some other information is from ctx. Can I do something with that ctx get unique id. 

Thanks

On Wed 12 Dec, 2018, 7:56 PM Jakob Bohm via openssl-users <[hidden email] wrote:
On 12/12/2018 12:54, ASHIQUE CK wrote:
> Hi,
> Any help on this ?
>
> On Wed, Dec 12, 2018 at 3:03 PM ASHIQUE CK <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>     We are using a Crypto Accelerator Engine to offload AESGCM and RSA
>     parameters. Trying to connect multiple clients simultaneously with
>     a single Nginx server, which is using this accelerator.  The Key
>     and IV is passing only at handshake, and after handshake this set
>     of key and IV is using for all encryption and decryption. So at
>     Engine side, we are storing this Key and IV to a buffer and while
>     encrypting/decrypting , this Key and IV is used from this buffer.
>     But, while multiple client connects, the last saved Key/IV is
>     getting for all clients.
>             So, is there any way to get a unique ID foer each client
>     connection ?
>
>
The following assumes that the accelerator is accessed using an
OpenSSL "engine" plugin, if instead you are inserting code in NGINX
to hand over the complete SSL/TLS record processing to the hardware,
then a different approach is needed.

OpenSSL Crypto Engines are not limited to SSL/TLS but can be used
for other tasks using the OpenSSL libcrypto library.

Thus the way this works is that the SSL/TLS requests an EVP "handle"
for each key that it wants to use, this handle then maps (indirectly)
to a structure passed to the engine, which is unique to each key.

A correctly implemented engine is supposed to use that structure to
tell the difference between different keys stored in the actual
hardware.

For the case of GCM key/IV pairs, it may be that in some situations
OpenSSL requests more than one EVP key instance for the same key,
typically to allow each to have its own independent state (for GCM,
this is the counter, for CBC it would be the IV chaining from block
to block).  The simple solution is to just treat them as different
keys, but if this uses too many hardware key storage locations, an
engine may use some way to recognize the reused key, share the
hardware object and keep count of how many "handles" point to that
key.



Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

Michael Richardson
In reply to this post by ASHIQUE CK

ASHIQUE CK <[hidden email]> wrote:
> We are using a Crypto Accelerator Engine to offload AESGCM and RSA
> parameters. Trying to connect multiple clients simultaneously with a
> single Nginx server, which is using this accelerator. The Key and IV

You probably need to tell us:

1) which engine?  did you write this engine?
2) whose driver?
3) what version of openssl?
4) what version of nginx?
5) how did you observe the problem you described?
6) is it different for, for instance, apache?  or some other server software?

> is passing only at handshake, and after handshake this set of key and
> IV is using for all encryption and decryption. So at Engine side, we
> are storing this Key and IV to a buffer and while
> encrypting/decrypting , this Key and IV is used from this buffer. But,
> while multiple client connects, the last saved Key/IV is getting for
> all clients.
> So, is there any way to get a unique ID foer each client connection ?
>

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

ASHIQUE CK
Hi,
1. The engine that we wrote is by the reference of qat, is just an interface which receives the openssl parameters of AES and RSA and offload them to an FPGA hardware accelerator. 
2. 
3. Openssl 1.1.0 h
4. Uses f-stack nginx 1.10.1
5. We ran nginx server which have a 1 Gb file in its root directory. Then connected 3 clients to this server. These clients waits after handshake is done. After I run 3rd client, I gave a Get request through 1 st client to download that 1 gb file. But it showed error message, "decryption failed or bad record mac". When I debugged using gdb, I understood that Tag verification is getting failed. But the matter is, I am storing the Key and IV at the time of handshake itself, to a buffer in my engine. When an SSLRead or SSLWrite occur, I will copy the saved Key and Iv to fill the respective descriptors. 
      But, in this case what happens is, if there is 3rd client handshake occurred, its key and iv stored in a buffer. And when I give a Sslwrite in the 1st client, it used the last saved key and iv, but it is actually key and iv of 3 rd client. But I can download the file if I give get request through the last handshaked client. 
     So what I can do is, save the key and iv of different clients in different buffers. If the SSLread/write from any client comes, then just offload the key and iv from the respective buffer. But for that, i need a unique id for each client, which must be the same for a client in the entire connection. 
    How can i get the unique id. Beyond the parameters *in, *out, inl (in the case of plaintext/ cipher text offloading) and *ptr, *type, *arg (in the case of header/aad offload) only what I have is ctx. With this ctx, can i get a unique id or is there any way to solve this problem. 
6. Didn't tried with Apache server.

Thanks

On Thu 13 Dec, 2018, 1:30 AM Michael Richardson <[hidden email] wrote:

ASHIQUE CK <[hidden email]> wrote:
> We are using a Crypto Accelerator Engine to offload AESGCM and RSA
> parameters. Trying to connect multiple clients simultaneously with a
> single Nginx server, which is using this accelerator. The Key and IV

You probably need to tell us:

1) which engine?  did you write this engine?
2) whose driver?
3) what version of openssl?
4) what version of nginx?
5) how did you observe the problem you described?
6) is it different for, for instance, apache?  or some other server software?

> is passing only at handshake, and after handshake this set of key and
> IV is using for all encryption and decryption. So at Engine side, we
> are storing this Key and IV to a buffer and while
> encrypting/decrypting , this Key and IV is used from this buffer. But,
> while multiple client connects, the last saved Key/IV is getting for
> all clients.
> So, is there any way to get a unique ID foer each client connection ?
>
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

ASHIQUE CK
4. f-stack nginx server 1.11.10

On Thu, Dec 13, 2018 at 9:00 AM ASHIQUE CK <[hidden email]> wrote:
Hi,
1. The engine that we wrote is by the reference of qat, is just an interface which receives the openssl parameters of AES and RSA and offload them to an FPGA hardware accelerator. 
2. 
3. Openssl 1.1.0 h
4. Uses f-stack nginx 1.10.1
5. We ran nginx server which have a 1 Gb file in its root directory. Then connected 3 clients to this server. These clients waits after handshake is done. After I run 3rd client, I gave a Get request through 1 st client to download that 1 gb file. But it showed error message, "decryption failed or bad record mac". When I debugged using gdb, I understood that Tag verification is getting failed. But the matter is, I am storing the Key and IV at the time of handshake itself, to a buffer in my engine. When an SSLRead or SSLWrite occur, I will copy the saved Key and Iv to fill the respective descriptors. 
      But, in this case what happens is, if there is 3rd client handshake occurred, its key and iv stored in a buffer. And when I give a Sslwrite in the 1st client, it used the last saved key and iv, but it is actually key and iv of 3 rd client. But I can download the file if I give get request through the last handshaked client. 
     So what I can do is, save the key and iv of different clients in different buffers. If the SSLread/write from any client comes, then just offload the key and iv from the respective buffer. But for that, i need a unique id for each client, which must be the same for a client in the entire connection. 
    How can i get the unique id. Beyond the parameters *in, *out, inl (in the case of plaintext/ cipher text offloading) and *ptr, *type, *arg (in the case of header/aad offload) only what I have is ctx. With this ctx, can i get a unique id or is there any way to solve this problem. 
6. Didn't tried with Apache server.

Thanks

On Thu 13 Dec, 2018, 1:30 AM Michael Richardson <[hidden email] wrote:

ASHIQUE CK <[hidden email]> wrote:
> We are using a Crypto Accelerator Engine to offload AESGCM and RSA
> parameters. Trying to connect multiple clients simultaneously with a
> single Nginx server, which is using this accelerator. The Key and IV

You probably need to tell us:

1) which engine?  did you write this engine?
2) whose driver?
3) what version of openssl?
4) what version of nginx?
5) how did you observe the problem you described?
6) is it different for, for instance, apache?  or some other server software?

> is passing only at handshake, and after handshake this set of key and
> IV is using for all encryption and decryption. So at Engine side, we
> are storing this Key and IV to a buffer and while
> encrypting/decrypting , this Key and IV is used from this buffer. But,
> while multiple client connects, the last saved Key/IV is getting for
> all clients.
> So, is there any way to get a unique ID foer each client connection ?
>
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple client connection to Nginx server

Filipe Fernandes
Hi,

Socket file descriptor is unique during the entire connection time. You could save the data using the fd as key to a hashtable entry.

Regards 

Na(o) quinta, 13 de dez de 2018, 05:16, ASHIQUE CK <[hidden email]> escreveu:
4. f-stack nginx server 1.11.10

On Thu, Dec 13, 2018 at 9:00 AM ASHIQUE CK <[hidden email]> wrote:
Hi,
1. The engine that we wrote is by the reference of qat, is just an interface which receives the openssl parameters of AES and RSA and offload them to an FPGA hardware accelerator. 
2. 
3. Openssl 1.1.0 h
4. Uses f-stack nginx 1.10.1
5. We ran nginx server which have a 1 Gb file in its root directory. Then connected 3 clients to this server. These clients waits after handshake is done. After I run 3rd client, I gave a Get request through 1 st client to download that 1 gb file. But it showed error message, "decryption failed or bad record mac". When I debugged using gdb, I understood that Tag verification is getting failed. But the matter is, I am storing the Key and IV at the time of handshake itself, to a buffer in my engine. When an SSLRead or SSLWrite occur, I will copy the saved Key and Iv to fill the respective descriptors. 
      But, in this case what happens is, if there is 3rd client handshake occurred, its key and iv stored in a buffer. And when I give a Sslwrite in the 1st client, it used the last saved key and iv, but it is actually key and iv of 3 rd client. But I can download the file if I give get request through the last handshaked client. 
     So what I can do is, save the key and iv of different clients in different buffers. If the SSLread/write from any client comes, then just offload the key and iv from the respective buffer. But for that, i need a unique id for each client, which must be the same for a client in the entire connection. 
    How can i get the unique id. Beyond the parameters *in, *out, inl (in the case of plaintext/ cipher text offloading) and *ptr, *type, *arg (in the case of header/aad offload) only what I have is ctx. With this ctx, can i get a unique id or is there any way to solve this problem. 
6. Didn't tried with Apache server.

Thanks

On Thu 13 Dec, 2018, 1:30 AM Michael Richardson <[hidden email] wrote:

ASHIQUE CK <[hidden email]> wrote:
> We are using a Crypto Accelerator Engine to offload AESGCM and RSA
> parameters. Trying to connect multiple clients simultaneously with a
> single Nginx server, which is using this accelerator. The Key and IV

You probably need to tell us:

1) which engine?  did you write this engine?
2) whose driver?
3) what version of openssl?
4) what version of nginx?
5) how did you observe the problem you described?
6) is it different for, for instance, apache?  or some other server software?

> is passing only at handshake, and after handshake this set of key and
> IV is using for all encryption and decryption. So at Engine side, we
> are storing this Key and IV to a buffer and while
> encrypting/decrypting , this Key and IV is used from this buffer. But,
> while multiple client connects, the last saved Key/IV is getting for
> all clients.
> So, is there any way to get a unique ID foer each client connection ?
>
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users