openssl 1.1.1 opaque structures

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

openssl 1.1.1 opaque structures

priya p
Hi,

In openssl-1.1.1, few structures have been made opaque like HMAC_CTX, EVP_CIPHER_CTX etc.,
There are new API to get and set those structure members. But to zeroize those structure members in place, I dont see any API.
Eg : DH strcuture has members like pub_key, priv_key. To zeroize the priv_key , what API should be used ?


Can anyone clarify this ?

Thanks,
Priya

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

Re: openssl 1.1.1 opaque structures

Matt Caswell-2


On 20/11/2018 06:49, priya p wrote:

> Hi,
>
> In openssl-1.1.1, few structures have been made opaque like HMAC_CTX,
> EVP_CIPHER_CTX etc.,
> There are new API to get and set those structure members. But to zeroize those
> structure members in place, I dont see any API.
> Eg : DH strcuture has members like pub_key, priv_key. To zeroize the priv_key ,
> what API should be used ?
>
>
> Can anyone clarify this ?

In the case of DH, DH_free() also zeroizes.

Matt

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

Re: openssl 1.1.1 opaque structures

Michael Richardson
In reply to this post by priya p
priya p <[hidden email]> wrote:
    > In openssl-1.1.1, few structures have been made opaque like HMAC_CTX,
    > EVP_CIPHER_CTX etc.,

    > There are new API to get and set those structure members. But to
    > zeroize those structure members in place, I dont see any API.

"in place", do you mean because you've allocated them as auto variables
on the stack?

--
]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        | network architect  [
]     [hidden email]  http://www.sandelman.ca/        |   ruby on rails    [

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

Re: openssl 1.1.1 opaque structures

Matt Caswell-2


On 20/11/2018 15:27, Michael Richardson wrote:
> priya p <[hidden email]> wrote:
>     > In openssl-1.1.1, few structures have been made opaque like HMAC_CTX,
>     > EVP_CIPHER_CTX etc.,
>
>     > There are new API to get and set those structure members. But to
>     > zeroize those structure members in place, I dont see any API.
>
> "in place", do you mean because you've allocated them as auto variables
> on the stack?

It is not possible to allocate opaque structures on the stack. The compiler will
complain.

Matt

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

Re: openssl 1.1.1 opaque structures

priya p
Thanks Matt and Michael.

On Tue, 20 Nov 2018 at 20:59, Matt Caswell <[hidden email]> wrote:


On 20/11/2018 15:27, Michael Richardson wrote:
> priya p <[hidden email]> wrote:
>     > In openssl-1.1.1, few structures have been made opaque like HMAC_CTX,
>     > EVP_CIPHER_CTX etc.,
>
>     > There are new API to get and set those structure members. But to
>     > zeroize those structure members in place, I dont see any API.
>
> "in place", do you mean because you've allocated them as auto variables
> on the stack?

It is not possible to allocate opaque structures on the stack. The compiler will
complain.

Matt

--
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: openssl 1.1.1 opaque structures

priya p
Hi,       
  
In this snippet, 

       DH *dh;
              if ((dh->g = BN_new()) == NULL)-------------> 1
                     goto end;
             if (!BN_set_word(dh->g, g)) -----------------------> 2
                      goto end;

Here as we can't reference dh structure members directly,  how can we initialize and set it in case of 1 and 2 ?

Thanks,
Priya


On Tue, 20 Nov 2018 at 23:08, priya p <[hidden email]> wrote:
Thanks Matt and Michael.

On Tue, 20 Nov 2018 at 20:59, Matt Caswell <[hidden email]> wrote:


On 20/11/2018 15:27, Michael Richardson wrote:
> priya p <[hidden email]> wrote:
>     > In openssl-1.1.1, few structures have been made opaque like HMAC_CTX,
>     > EVP_CIPHER_CTX etc.,
>
>     > There are new API to get and set those structure members. But to
>     > zeroize those structure members in place, I dont see any API.
>
> "in place", do you mean because you've allocated them as auto variables
> on the stack?

It is not possible to allocate opaque structures on the stack. The compiler will
complain.

Matt

--
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: openssl 1.1.1 opaque structures

Matt Caswell-2


On 23/11/2018 10:33, priya p wrote:

> Hi,       
>   
> In this snippet, 
>
>        DH *dh;
>               if ((dh->g = BN_new()) == NULL)-------------> 1
>                      goto end;
>              if (!BN_set_word(dh->g, g)) -----------------------> 2
>                       goto end;
>
> Here as we can't reference dh structure members directly,  how can we initialize
> and set it in case of 1 and 2 ?

Use the DH_set0_pqg() function:

https://www.openssl.org/docs/man1.1.1/man3/DH_set0_pqg.html

You must also set p at the same time.

Matt

>
> Thanks,
> Priya
>
>
> On Tue, 20 Nov 2018 at 23:08, priya p <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Thanks Matt and Michael.
>
>     On Tue, 20 Nov 2018 at 20:59, Matt Caswell <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>
>
>         On 20/11/2018 15:27, Michael Richardson wrote:
>         > priya p <[hidden email] <mailto:[hidden email]>> wrote:
>         >     > In openssl-1.1.1, few structures have been made opaque like
>         HMAC_CTX,
>         >     > EVP_CIPHER_CTX etc.,
>         >
>         >     > There are new API to get and set those structure members. But to
>         >     > zeroize those structure members in place, I dont see any API.
>         >
>         > "in place", do you mean because you've allocated them as auto variables
>         > on the stack?
>
>         It is not possible to allocate opaque structures on the stack. The
>         compiler will
>         complain.
>
>         Matt
>
>         --
>         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: openssl 1.1.1 opaque structures

Richard Levitte - VMS Whacker-2
In reply to this post by priya p
In message <[hidden email]> on Fri, 23 Nov 2018 10:33:48 +0000, [hidden email] said:

> Hi,
>
> In this snippet,
>
>        DH *dh;
>               if ((dh->g = BN_new()) == NULL)-------------> 1
>                      goto end;
>              if (!BN_set_word(dh->g, g)) -----------------------> 2
>                       goto end;

    DH *dh;
    BIGNUM *bn_g;

    if ((bn_g= BN_new()) == NULL)
        goto end;
    if (!BN_set_word(bn_g, g))
        goto end;
    if (!DH_set0_pqg(dh, NULL, NULL, bn_g))
        goto end;

Note that if the p parameter hasn't been set in dh, you must give that
one too, so essentially, this is safer:

    if (!DH_set0_pqg(dh, bn_p, NULL, bn_g))
        goto end;

See the manual pages for DH_set0_pqg and DH_get0_pqg

Cheers,
Richard

--
Richard Levitte         [hidden email]
OpenSSL Project         http://www.openssl.org/~levitte/
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: openssl 1.1.1 opaque structures

priya p
Thanks Matt and Richard.

BIGNUM structure also has been made opaque. How to refer the members of BIGNUM structure like bn->top ?
And I don't see this API implementation ""lh_OPENSSL_CSTRING_new" in openssl-1.1.1 ?
Is it removed ?

Thanks,
Priya


On Fri, 23 Nov 2018 at 16:59, Richard Levitte <[hidden email]> wrote:
In message <[hidden email]> on Fri, 23 Nov 2018 10:33:48 +0000, [hidden email] said:

> Hi,
>
> In this snippet,
>
>        DH *dh;
>               if ((dh->g = BN_new()) == NULL)-------------> 1
>                      goto end;
>              if (!BN_set_word(dh->g, g)) -----------------------> 2
>                       goto end;

    DH *dh;
    BIGNUM *bn_g;

    if ((bn_g= BN_new()) == NULL)
        goto end;
    if (!BN_set_word(bn_g, g))
        goto end;
    if (!DH_set0_pqg(dh, NULL, NULL, bn_g))
        goto end;

Note that if the p parameter hasn't been set in dh, you must give that
one too, so essentially, this is safer:

    if (!DH_set0_pqg(dh, bn_p, NULL, bn_g))
        goto end;

See the manual pages for DH_set0_pqg and DH_get0_pqg

Cheers,
Richard

--
Richard Levitte         [hidden email]
OpenSSL Project         http://www.openssl.org/~levitte/
--
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: openssl 1.1.1 opaque structures

OpenSSL - User mailing list
  • BIGNUM structure also has been made opaque. How to refer the members of BIGNUM structure like bn->top ?

 

You cannot.  That is the definition of “opaque structure.” :) Why do you need to access “top” ?

 

  • And I don't see this API implementation ""lh_OPENSSL_CSTRING_new" in openssl-1.1.1 ?

 

It is a static inline functions in include/openssl/safestack.h.  Because it’s static-inline, it won’t show up unless it is actually used.


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

Re: openssl 1.1.1 opaque structures

priya p
Hi Matt, 

I want to get/set BIGNUM structure members using API like DH getter/setter ?

Thanks, 
Priya 

On Sun, Nov 25, 2018, 9:32 AM Salz, Rich via openssl-users <[hidden email] wrote:
  • BIGNUM structure also has been made opaque. How to refer the members of BIGNUM structure like bn->top ?

 

You cannot.  That is the definition of “opaque structure.” :) Why do you need to access “top” ?

 

  • And I don't see this API implementation ""lh_OPENSSL_CSTRING_new" in openssl-1.1.1 ?

 

It is a static inline functions in include/openssl/safestack.h.  Because it’s static-inline, it won’t show up unless it is actually used.

--
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: openssl 1.1.1 opaque structures

Richard Levitte - VMS Whacker-2
(that was Rich responding, not Matt ;-))

There are penty of functions to assign values properly to BIGNUMs
without having to resort to accessing the structure members.  If you
still have reasons to do so, that sounds like you want to modify the
API somehow, and since you do have access to the OpenSSL source,
you're free to do so (and to maintain your own patches).

Cheers,
Richard

In message <CAAiJU8P2TNALbhfYCr-W6qEQXEZ3=[hidden email]> on Sun, 25 Nov 2018 11:05:52 +0530, priya p <[hidden email]> said:

> Hi Matt,
>
> I want to get/set BIGNUM structure members using API like DH getter/setter ?
>
> Thanks,
> Priya
>
> On Sun, Nov 25, 2018, 9:32 AM Salz, Rich via openssl-users <[hidden email] wrote:
>
>  * BIGNUM structure also has been made opaque. How to refer the members of BIGNUM
>  structure like bn->top ?
>
>  You cannot. That is the definition of “opaque structure.” :) Why do you need to access “top” ?
>
>  * And I don't see this API implementation ""lh_OPENSSL_CSTRING_new" in openssl-1.1.1 ?
>
>  It is a static inline functions in include/openssl/safestack.h. Because it’s static-inline, it won’t
>  show up unless it is actually used.
>
>  --
>  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: openssl 1.1.1 opaque structures

priya p
Hi Richard,

I am unable to get the API to access bn->top value  or any bn members in openssl 1.1.1 .
Can you help me with the pointers to those APIs ?

And  I dont see "lh_OPENSSL_CSTRING_new " function in "include/openssl/safestack.h" ?
Please correct me if I am wrong .

Thanks,
Priya


On Sun, 25 Nov 2018 at 11:56, Richard Levitte <[hidden email]> wrote:
(that was Rich responding, not Matt ;-))

There are penty of functions to assign values properly to BIGNUMs
without having to resort to accessing the structure members.  If you
still have reasons to do so, that sounds like you want to modify the
API somehow, and since you do have access to the OpenSSL source,
you're free to do so (and to maintain your own patches).

Cheers,
Richard

In message <CAAiJU8P2TNALbhfYCr-W6qEQXEZ3=[hidden email]> on Sun, 25 Nov 2018 11:05:52 +0530, priya p <[hidden email]> said:

> Hi Matt,
>
> I want to get/set BIGNUM structure members using API like DH getter/setter ?
>
> Thanks,
> Priya
>
> On Sun, Nov 25, 2018, 9:32 AM Salz, Rich via openssl-users <[hidden email] wrote:
>
>  * BIGNUM structure also has been made opaque. How to refer the members of BIGNUM
>  structure like bn->top ?
>
>  You cannot. That is the definition of “opaque structure.” :) Why do you need to access “top” ?
>
>  * And I don't see this API implementation ""lh_OPENSSL_CSTRING_new" in openssl-1.1.1 ?
>
>  It is a static inline functions in include/openssl/safestack.h. Because it’s static-inline, it won’t
>  show up unless it is actually used.
>
>  --
>  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
Reply | Threaded
Open this post in threaded view
|

Re: openssl 1.1.1 opaque structures

Viktor Dukhovni
> On Nov 26, 2018, at 12:14 AM, priya p <[hidden email]> wrote:
>
> I am unable to get the API to access bn->top value  or any bn members in openssl 1.1.1 .
> Can you help me with the pointers to those APIs ?

What actual problem are you trying to solve?  Accessing bn->top is
a goal in itself.

--
        Viktor.

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

Re: openssl 1.1.1 opaque structures

priya p
I am trying to fix this part of code:

 int Func1 (var, bn) {
*var = rc_vmalloc(bn->top * BN_BYTES); ------------------> Trying to fix this. Error it throws is " error: dereferencing pointer to incomplete type".

 (*var)->l = BN_bn2bin(bn, (unsigned char *)(*var)->v);
.
.
}

Thanks,
Priya


On Mon, 26 Nov 2018 at 11:06, Viktor Dukhovni <[hidden email]> wrote:
> On Nov 26, 2018, at 12:14 AM, priya p <[hidden email]> wrote:
>
> I am unable to get the API to access bn->top value  or any bn members in openssl 1.1.1 .
> Can you help me with the pointers to those APIs ?

What actual problem are you trying to solve?  Accessing bn->top is
a goal in itself.

--
        Viktor.

--
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: openssl 1.1.1 opaque structures

Viktor Dukhovni
> On Nov 26, 2018, at 12:45 AM, priya p <[hidden email]> wrote:
>
> I am trying to fix this part of code:
>
>  int Func1 (var, bn) {
> *var = rc_vmalloc(bn->top * BN_BYTES); ------------------> Trying to fix this. Error it throws is " error: dereferencing pointer to incomplete type".
>
>  (*var)->l = BN_bn2bin(bn, (unsigned char *)(*var)->v);
> .
> .
> }

Have you considered looking at the BN_bn2bin documentation?

   https://www.openssl.org/docs/man1.0.2/crypto/BN_bn2bin.html

   SYNOPSIS:
       int BN_bn2bin(const BIGNUM *a, unsigned char *to);

   DESCRIPTION:

       BN_bn2bin() converts the absolute value of a into big-endian form and
       stores it at to. to must point to BN_num_bytes(a) bytes of memory.

--
        Viktor.

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

Re: openssl 1.1.1 opaque structures

OpenSSL - User mailing list
In reply to this post by priya p
  • I am unable to get the API to access bn->top value  or any bn members in openssl 1.1.1 .

Can you help me with the pointers to those APIs ?

 

They do not exist.  This is the first time someone has asked for them.  You will need to open an issue on GitHub, and explain *why* you need access.

 

  • And  I dont see "lh_OPENSSL_CSTRING_new " function in "include/openssl/safestack.h" ?

 

Look for “DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING” near the end of the file.  Then trace through the macros.


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

Re: openssl 1.1.1 opaque structures

Richard Levitte - VMS Whacker-2
In reply to this post by priya p
Did you ever get an answer to that?  There is a call BN_num_bytes(),
so the fix should be this:

    *var = rc_vmalloc(BN_num_bytes(bn));
    (*var)->l = BN_bn2bin(bn, (unsigned char *)(*var)->v);

Cheers,
Richard ( you should probably study include/openssl/bn.h in depth )

In message <[hidden email]> on Mon, 26 Nov 2018 11:15:27 +0530, priya p <[hidden email]> said:

> I am trying to fix this part of code:
>
> int Func1 (var, bn) {
> *var = rc_vmalloc(bn->top * BN_BYTES); ------------------> Trying to fix this. Error it throws is " error:
> dereferencing pointer to incomplete type".
>
> (*var)->l = BN_bn2bin(bn, (unsigned char *)(*var)->v);
> .
> .
> }
>
> Thanks,
> Priya
>
> On Mon, 26 Nov 2018 at 11:06, Viktor Dukhovni <[hidden email]> wrote:
>
>  > On Nov 26, 2018, at 12:14 AM, priya p <[hidden email]> wrote:
>  >
>  > I am unable to get the API to access bn->top value or any bn members in openssl 1.1.1 .
>  > Can you help me with the pointers to those APIs ?
>
>  What actual problem are you trying to solve? Accessing bn->top is
>  a goal in itself.
>
>  --
>  Viktor.
>
>  --
>  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