Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread ASHIQUE CK
4. f-stack nginx server 1.11.10

On Thu, Dec 13, 2018 at 9:00 AM ASHIQUE CK  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 
>>
>> ASHIQUE CK  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


Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread 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 
> ASHIQUE CK  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


Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread Michael Richardson

ASHIQUE CK  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 ?
>


signature.asc
Description: PGP signature
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread 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 <
openssl-users@openssl.org 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  > > 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


Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread Jakob Bohm via openssl-users

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 > 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


Re: [openssl-users] RSA Public Key error

2018-12-12 Thread Erwann Abalea via openssl-users
Bonjour,

Assuming the first 24 bytes you’re talking about are the very beginning of the 
SPKI structure (that is, the enclosing SEQUENCE, and the AlgorithmIdentifier), 
that means you’ve replaced up to the first byte of the BITSTRING containing the 
public key (this byte indicates the number of unused bits) for a 2048bits RSA 
key with 16 custom bytes.
That’s perfectly normal for OpenSSL to refuse to load that beast, and for 
asn1parse to return errors (the first bytes do not represent a correct DER 
encoding of anything).
Think of it as « I took a Jpeg file, replaced some bytes at the beginning by my 
own, and now I can’t open the file again ». Those bytes are there for a reason.

A quick solution would be to *add* your 16 bytes before the public key, and 
remove them when passing the rest of the bytes to OpenSSL.

Cordialement,
Erwann Abalea


De : openssl-users  au nom de prithiraj das 

Répondre à : "openssl-users@openssl.org" 
Date : mercredi 12 décembre 2018 à 08:08
À : "openssl-users@openssl.org" 
Objet : [openssl-users] RSA Public Key error

Hi,

I have a RSA public key(PKCS 1v1.5) that I have obtained from somewhere. That 
key has been obtained after removing the first 24 bytes from the originally 
generated RSA public key. Those 24 bytes are being replaced by some custom 16 
byte information which is being used as some sort of identifier in some future 
task and those 16 bytes are playing no role in encryption. OpenSSL fails to 
read this key. asn1parse shows some parsing error and most importantly RSA 
encryption in OpenSSL using this key fails. The untampered version of the RSA 
public key generated from the same source and containing the original 24 bytes 
at the beginning of the key is successfully read by OpenSSL and the RSA 
encryption using that key is also successful in OpenSSL. But our requirement is 
to use the first key containing the custom 16 byte information.

My understanding is that the first 24 bytes of RSA public key following PKCS 
standards doesn't contain the modulus and exponent details required for RSA 
encryption.  But OpenSSL seems to require these 24 bytes for encryption. Can 
someone please confirm what kind of information is present in the first 24 
bytes of RSA Public key and/or why does OpenSSL need it? If possible, please 
suggest a solution to work with that RSA public key containing custom 16 byte 
information at the beginning of the key.


Thanks and Regards,
Prithiraj
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


Re: [openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread ASHIQUE CK
Hi,
Any help on this ?

On Wed, Dec 12, 2018 at 3:03 PM ASHIQUE CK  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


[openssl-users] Multiple client connection to Nginx server

2018-12-12 Thread 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