Problems with man page code example at EVP_EncryptInit

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

Problems with man page code example at EVP_EncryptInit

Sam Habiel
First time poster. I hope I am writing to the right place.

Example for "General encryption and decryption function example using
FILE I/O and AES128 with a 128-bit key" has two errors. I spent a lot
of time trying to figure out what I did wrong for a while...

1. ctx is already a pointer; it does not need to be indirected to get
the pointer.

        EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
do_encrypt);

should say:

        EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL, do_encrypt);

2. ciphertext length is not used to update write position:

                if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
and

        if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen))

should say (what worked for me):

                if(!EVP_CipherUpdate(ctx, outbuf + outlen, &outlen,
inbuf, inlen))

and
        if(!EVP_CipherFinal_ex(ctx, outbuf + outlen, &outlen))

It would be nice if there is a complete example that compiles and has
a main() to run it.

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

Re: Problems with man page code example at EVP_EncryptInit

Sam Habiel
I had to double check something--I was wrong about something--&outlen
is not incremented inside of openssl--so you have to keep another
variable to which you add outlen and use that to set the read/write
pointer in outbuf.

--Sam
On Wed, Sep 5, 2018 at 10:04 AM Sam Habiel <[hidden email]> wrote:

>
> First time poster. I hope I am writing to the right place.
>
> Example for "General encryption and decryption function example using
> FILE I/O and AES128 with a 128-bit key" has two errors. I spent a lot
> of time trying to figure out what I did wrong for a while...
>
> 1. ctx is already a pointer; it does not need to be indirected to get
> the pointer.
>
>         EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
> do_encrypt);
>
> should say:
>
>         EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL, do_encrypt);
>
> 2. ciphertext length is not used to update write position:
>
>                 if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
> and
>
>         if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen))
>
> should say (what worked for me):
>
>                 if(!EVP_CipherUpdate(ctx, outbuf + outlen, &outlen,
> inbuf, inlen))
>
> and
>         if(!EVP_CipherFinal_ex(ctx, outbuf + outlen, &outlen))
>
> It would be nice if there is a complete example that compiles and has
> a main() to run it.
>
> --Sam
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems with man page code example at EVP_EncryptInit

OpenSSL - User mailing list
PRs on GitHub to fix documentation are always welcome.
--
-Todd Short
// "One if by land, two if by sea, three if by the Internet."

On Sep 5, 2018, at 10:18 AM, Sam Habiel <[hidden email]> wrote:

I had to double check something--I was wrong about something--&outlen
is not incremented inside of openssl--so you have to keep another
variable to which you add outlen and use that to set the read/write
pointer in outbuf.

--Sam
On Wed, Sep 5, 2018 at 10:04 AM Sam Habiel <[hidden email]> wrote:

First time poster. I hope I am writing to the right place.

Example for "General encryption and decryption function example using
FILE I/O and AES128 with a 128-bit key" has two errors. I spent a lot
of time trying to figure out what I did wrong for a while...

1. ctx is already a pointer; it does not need to be indirected to get
the pointer.

       EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
do_encrypt);

should say:

       EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL, do_encrypt);

2. ciphertext length is not used to update write position:

               if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
and

       if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen))

should say (what worked for me):

               if(!EVP_CipherUpdate(ctx, outbuf + outlen, &outlen,
inbuf, inlen))

and
       if(!EVP_CipherFinal_ex(ctx, outbuf + outlen, &outlen))

It would be nice if there is a complete example that compiles and has
a main() to run it.

--Sam
--
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: Problems with man page code example at EVP_EncryptInit

Sam Habiel
Todd,

What is the correct repo on Github?

--Sam
On Wed, Sep 5, 2018 at 10:46 AM Short, Todd via openssl-users
<[hidden email]> wrote:

>
> PRs on GitHub to fix documentation are always welcome.
> --
> -Todd Short
> // [hidden email]
> // "One if by land, two if by sea, three if by the Internet."
>
> On Sep 5, 2018, at 10:18 AM, Sam Habiel <[hidden email]> wrote:
>
> I had to double check something--I was wrong about something--&outlen
> is not incremented inside of openssl--so you have to keep another
> variable to which you add outlen and use that to set the read/write
> pointer in outbuf.
>
> --Sam
> On Wed, Sep 5, 2018 at 10:04 AM Sam Habiel <[hidden email]> wrote:
>
>
> First time poster. I hope I am writing to the right place.
>
> Example for "General encryption and decryption function example using
> FILE I/O and AES128 with a 128-bit key" has two errors. I spent a lot
> of time trying to figure out what I did wrong for a while...
>
> 1. ctx is already a pointer; it does not need to be indirected to get
> the pointer.
>
>        EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
> do_encrypt);
>
> should say:
>
>        EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL, do_encrypt);
>
> 2. ciphertext length is not used to update write position:
>
>                if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
> and
>
>        if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen))
>
> should say (what worked for me):
>
>                if(!EVP_CipherUpdate(ctx, outbuf + outlen, &outlen,
> inbuf, inlen))
>
> and
>        if(!EVP_CipherFinal_ex(ctx, outbuf + outlen, &outlen))
>
> It would be nice if there is a complete example that compiles and has
> a main() to run it.
>
> --Sam
>
> --
> 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: Problems with man page code example at EVP_EncryptInit

Sam Habiel
Never mind. Easy google search away: https://github.com/openssl/openssl
On Wed, Sep 5, 2018 at 10:49 AM Sam Habiel <[hidden email]> wrote:

>
> Todd,
>
> What is the correct repo on Github?
>
> --Sam
> On Wed, Sep 5, 2018 at 10:46 AM Short, Todd via openssl-users
> <[hidden email]> wrote:
> >
> > PRs on GitHub to fix documentation are always welcome.
> > --
> > -Todd Short
> > // [hidden email]
> > // "One if by land, two if by sea, three if by the Internet."
> >
> > On Sep 5, 2018, at 10:18 AM, Sam Habiel <[hidden email]> wrote:
> >
> > I had to double check something--I was wrong about something--&outlen
> > is not incremented inside of openssl--so you have to keep another
> > variable to which you add outlen and use that to set the read/write
> > pointer in outbuf.
> >
> > --Sam
> > On Wed, Sep 5, 2018 at 10:04 AM Sam Habiel <[hidden email]> wrote:
> >
> >
> > First time poster. I hope I am writing to the right place.
> >
> > Example for "General encryption and decryption function example using
> > FILE I/O and AES128 with a 128-bit key" has two errors. I spent a lot
> > of time trying to figure out what I did wrong for a while...
> >
> > 1. ctx is already a pointer; it does not need to be indirected to get
> > the pointer.
> >
> >        EVP_CipherInit_ex(&ctx, EVP_aes_128_cbc(), NULL, NULL, NULL,
> > do_encrypt);
> >
> > should say:
> >
> >        EVP_CipherInit_ex(ctx, EVP_aes_128_cbc(), NULL, NULL, NULL, do_encrypt);
> >
> > 2. ciphertext length is not used to update write position:
> >
> >                if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen))
> > and
> >
> >        if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen))
> >
> > should say (what worked for me):
> >
> >                if(!EVP_CipherUpdate(ctx, outbuf + outlen, &outlen,
> > inbuf, inlen))
> >
> > and
> >        if(!EVP_CipherFinal_ex(ctx, outbuf + outlen, &outlen))
> >
> > It would be nice if there is a complete example that compiles and has
> > a main() to run it.
> >
> > --Sam
> >
> > --
> > 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