EVP_SignFinal third parameter type

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

EVP_SignFinal third parameter type

Silvia Gisela Pavon Velasco




I'm trying to sign a file and when I try to compile it I get the following
warning in the EVP_SignFinal function:

$ cc -o sign_test -I/opt/openssl/include -lssl -lcrypto sign_test.c
cc: "sign_test.c", line 43: warning 604: Pointers are not
assignment-compatible.
cc: "sign_test.c", line 43: warning 563: Argument #3 is not the correct
type.

Although that warning I run the program but I get the next output:

$ sign_test
Key Size is 128 bytes
Sign size is

How should I declare the bytes_firma variable? Or the error is somewhere
else?

Code extract:
*******************************************************************
   // Signing
   unsigned char *firma;
   int           bytes_leidos;
   int           bytes_firma;
   EVP_MD_CTX    ctx;
   char          buf[TAM_BUF];
   int           err;

   firma = (unsigned char *) malloc(EVP_PKEY_size(clave_EVP));

   EVP_SignInit_ex(&ctx, EVP_md5(), NULL);
   while (!feof(fp_ext)){
     bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);
     EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);
   }//while

   err = EVP_SignFinal(&ctx, firma, &bytes_firma, clave_EVP);m <-- in this
line occurs the error
   if (err != 1){
     ERR_print_errors_fp(stderr);
     exit (1);
   }//if

   printf("Sign size is %s\n",bytes_firma);

   free(firma);
   EVP_PKEY_free(clave_EVP);

*******************************************************************
Silvia Pavon

_________________________________________________________________________________
NOTA: La información de este correo es de propiedad exclusiva y
confidencial. Este mensaje es sólo para el destinatario señalado, si usted
no lo es, destrúyalo de inmediato. Ninguna información aquí contenida debe
ser entendida como dada o avalada por Alestra, sus subsidiarias o sus
empleados, salvo cuando ello expresamente se indique. Es responsabilidad de
quien recibe este correo de asegurarse que esté libre de virus, por lo
tanto ni Alestra, sus subsidiarias ni sus empleados aceptan responsabilidad
alguna.
NOTE:  The information in this email is proprietary and confidential. This
message is for the designated recipient only, if you are not the intended
recipient, you should destroy it immediately. Any information in this
message shall not be understood as given or endorsed by Alestra, its
subsidiaries or their employees, unless expressly so stated. It is the
responsibility of the recipient to ensure that this email is virus free,
therefore neither Alestra, its subsidiaries nor their employees accept any
responsibility.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Nils Larsch
Silvia Gisela Pavon Velasco wrote:

>
>
>
> I'm trying to sign a file and when I try to compile it I get the following
> warning in the EVP_SignFinal function:
>
> $ cc -o sign_test -I/opt/openssl/include -lssl -lcrypto sign_test.c
> cc: "sign_test.c", line 43: warning 604: Pointers are not
> assignment-compatible.
> cc: "sign_test.c", line 43: warning 563: Argument #3 is not the correct
> type.

the third argument should be a pointer to a "unsigned int"

>
> Although that warning I run the program but I get the next output:
>
> $ sign_test
> Key Size is 128 bytes
> Sign size is
>
> How should I declare the bytes_firma variable? Or the error is somewhere
> else?
>
> Code extract:
> *******************************************************************
>    // Signing
>    unsigned char *firma;
>    int           bytes_leidos;
>    int           bytes_firma;
>    EVP_MD_CTX    ctx;
>    char          buf[TAM_BUF];
>    int           err;
>
>    firma = (unsigned char *) malloc(EVP_PKEY_size(clave_EVP));
>
>    EVP_SignInit_ex(&ctx, EVP_md5(), NULL);
>    while (!feof(fp_ext)){
>      bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);
>      EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);
>    }//while
>
>    err = EVP_SignFinal(&ctx, firma, &bytes_firma, clave_EVP);m <-- in this
> line occurs the error
>    if (err != 1){
>      ERR_print_errors_fp(stderr);
>      exit (1);
>    }//if
>
>    printf("Sign size is %s\n",bytes_firma);

you might try %d instead of %s ;-)

Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Silvia Gisela Pavon Velasco




Nils,
I changed to %d instead of %s it worked  =)

But althougth I changed the declaration of the third argument to:
unsigned int  *bytes_firma;
I'm still getting the warning at compilation time.

If I let:
unsigned int  *bytes_firma;     and
err = EVP_SignFinal(&ctx, firma, bytes_firma, clave_EVP);

The warning goes away but the program crashes with "Bus error(coredump)"

Shouldn't I care about the warning? I'm concern that the warning means that
Im not signing well.

Another question: I have to save the signature in a file in a base64
format, any clues how can I do this?


Silvia G. Pavón V.
Procesos de Facturación
Alestra S.A.
Tel. 8748 6100 x4107


                                                                       
             Nils Larsch                                              
             <[hidden email]>                                        
             Sent by:                                                   To
             owner-openssl-use         [hidden email]      
             [hidden email]                                             cc
                                                                       
                                                                   Subject
             27/05/2005 04:29          Re: EVP_SignFinal third parameter
             p.m.                      type                            
                                                                       
                                                                       
             Please respond to                                        
             openssl-users@ope                                        
                 nssl.org                                              
                                                                       
                                                                       




Silvia Gisela Pavon Velasco wrote:
>
>
>
> I'm trying to sign a file and when I try to compile it I get the
following
> warning in the EVP_SignFinal function:
>
> $ cc -o sign_test -I/opt/openssl/include -lssl -lcrypto sign_test.c
> cc: "sign_test.c", line 43: warning 604: Pointers are not
> assignment-compatible.
> cc: "sign_test.c", line 43: warning 563: Argument #3 is not the correct
> type.

the third argument should be a pointer to a "unsigned int"

>
> Although that warning I run the program but I get the next output:
>
> $ sign_test
> Key Size is 128 bytes
> Sign size is
>
> How should I declare the bytes_firma variable? Or the error is somewhere
> else?
>
> Code extract:
> *******************************************************************
>    // Signing
>    unsigned char *firma;
>    int           bytes_leidos;
>    int           bytes_firma;
>    EVP_MD_CTX    ctx;
>    char          buf[TAM_BUF];
>    int           err;
>
>    firma = (unsigned char *) malloc(EVP_PKEY_size(clave_EVP));
>
>    EVP_SignInit_ex(&ctx, EVP_md5(), NULL);
>    while (!feof(fp_ext)){
>      bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);
>      EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);
>    }//while
>
>    err = EVP_SignFinal(&ctx, firma, &bytes_firma, clave_EVP);m <-- in
this
> line occurs the error
>    if (err != 1){
>      ERR_print_errors_fp(stderr);
>      exit (1);
>    }//if
>
>    printf("Sign size is %s\n",bytes_firma);

you might try %d instead of %s ;-)

Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Goetz Babin-Ebell
Silvia Gisela Pavon Velasco wrote:
> Nils,
Hello Silvia,
> I changed to %d instead of %s it worked  =)
>
> But althougth I changed the declaration of the third argument to:
> unsigned int  *bytes_firma;
> I'm still getting the warning at compilation time.
>
> If I let:
> unsigned int  *bytes_firma;     and
> err = EVP_SignFinal(&ctx, firma, bytes_firma, clave_EVP);

the third parameter is an IO parameter:

unsigned int   bytes_firma = EVP_PKEY_size(clave_EVP);
unsigned char *firma       = malloc(bytes_firma);

[...]

err = EVP_SignFinal(&ctx,firma,&bytes_firma,clave_EVP);

[...]


Bye

Goetz

--
DMCA: The greed of the few outweighs the freedom of the many

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Ivan Fraixedes
In reply to this post by Silvia Gisela Pavon Velasco
Silvia Gisela Pavon Velasco wrote:

>
>
>I'm trying to sign a file and when I try to compile it I get the following
>warning in the EVP_SignFinal function:
>
>$ cc -o sign_test -I/opt/openssl/include -lssl -lcrypto sign_test.c
>cc: "sign_test.c", line 43: warning 604: Pointers are not
>assignment-compatible.
>cc: "sign_test.c", line 43: warning 563: Argument #3 is not the correct
>type.
>
>Although that warning I run the program but I get the next output:
>
>$ sign_test
>Key Size is 128 bytes
>Sign size is
>
>How should I declare the bytes_firma variable? Or the error is somewhere
>else?
>
>Code extract:
>*******************************************************************
>   // Signing
>   unsigned char *firma;
>   int           bytes_leidos;
>   int           bytes_firma;
>   EVP_MD_CTX    ctx;
>   char          buf[TAM_BUF];
>   int           err;
>
>   firma = (unsigned char *) malloc(EVP_PKEY_size(clave_EVP));
>
>   EVP_SignInit_ex(&ctx, EVP_md5(), NULL);
>   while (!feof(fp_ext)){
>     bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);
>     EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);
>   }//while
>
>   err = EVP_SignFinal(&ctx, firma, &bytes_firma, clave_EVP);m <-- in this
>line occurs the error
>   if (err != 1){
>     ERR_print_errors_fp(stderr);
>     exit (1);
>   }//if
>
>   printf("Sign size is %s\n",bytes_firma);
>
>   free(firma);
>   EVP_PKEY_free(clave_EVP);
>
>*******************************************************************
>Silvia Pavon
>
>_________________________________________________________________________________
>NOTA: La información de este correo es de propiedad exclusiva y
>confidencial. Este mensaje es sólo para el destinatario señalado, si usted
>no lo es, destrúyalo de inmediato. Ninguna información aquí contenida debe
>ser entendida como dada o avalada por Alestra, sus subsidiarias o sus
>empleados, salvo cuando ello expresamente se indique. Es responsabilidad de
>quien recibe este correo de asegurarse que esté libre de virus, por lo
>tanto ni Alestra, sus subsidiarias ni sus empleados aceptan responsabilidad
>alguna.
>NOTE:  The information in this email is proprietary and confidential. This
>message is for the designated recipient only, if you are not the intended
>recipient, you should destroy it immediately. Any information in this
>message shall not be understood as given or endorsed by Alestra, its
>subsidiaries or their employees, unless expressly so stated. It is the
>responsibility of the recipient to ensure that this email is virus free,
>therefore neither Alestra, its subsidiaries nor their employees accept any
>responsibility.
>
>______________________________________________________________________
>OpenSSL Project                                 http://www.openssl.org
>User Support Mailing List                    [hidden email]
>Automated List Manager                           [hidden email]
>
>  
>
Hello,
the header of the EVP_SignFinal is:
int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s,
EVP_PKEY *pkey);

Therefore your bytes_firma variable should be of the type unsigned int,
not int.
I thing that for this reason you get a warning.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Ivan Fraixedes
In reply to this post by Silvia Gisela Pavon Velasco
I think that you should initialized the EVP_MD_CTX ctx with this function:
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);

or get a EVP_MD_CTX with this function:
EVP_MD_CTX *EVP_MD_CTX_create(void);

Good luck!



Silvia Gisela Pavon Velasco wrote:

>
>
>Nils,
>I changed to %d instead of %s it worked  =)
>
>But althougth I changed the declaration of the third argument to:
>unsigned int  *bytes_firma;
>I'm still getting the warning at compilation time.
>
>If I let:
>unsigned int  *bytes_firma;     and
>err = EVP_SignFinal(&ctx, firma, bytes_firma, clave_EVP);
>
>The warning goes away but the program crashes with "Bus error(coredump)"
>
>Shouldn't I care about the warning? I'm concern that the warning means that
>Im not signing well.
>
>Another question: I have to save the signature in a file in a base64
>format, any clues how can I do this?
>
>
>Silvia G. Pavón V.
>Procesos de Facturación
>Alestra S.A.
>Tel. 8748 6100 x4107
>
>
>                                                                          
>             Nils Larsch                                                  
>             <[hidden email]>                                            
>             Sent by:                                                   To
>             owner-openssl-use         [hidden email]          
>             [hidden email]                                             cc
>                                                                          
>                                                                   Subject
>             27/05/2005 04:29          Re: EVP_SignFinal third parameter  
>             p.m.                      type                                
>                                                                          
>                                                                          
>             Please respond to                                            
>             openssl-users@ope                                            
>                 nssl.org                                                  
>                                                                          
>                                                                          
>
>
>
>
>Silvia Gisela Pavon Velasco wrote:
>  
>
>>
>>I'm trying to sign a file and when I try to compile it I get the
>>    
>>
>following
>  
>
>>warning in the EVP_SignFinal function:
>>
>>$ cc -o sign_test -I/opt/openssl/include -lssl -lcrypto sign_test.c
>>cc: "sign_test.c", line 43: warning 604: Pointers are not
>>assignment-compatible.
>>cc: "sign_test.c", line 43: warning 563: Argument #3 is not the correct
>>type.
>>    
>>
>
>the third argument should be a pointer to a "unsigned int"
>
>  
>
>>Although that warning I run the program but I get the next output:
>>
>>$ sign_test
>>Key Size is 128 bytes
>>Sign size is
>>
>>How should I declare the bytes_firma variable? Or the error is somewhere
>>else?
>>
>>Code extract:
>>*******************************************************************
>>   // Signing
>>   unsigned char *firma;
>>   int           bytes_leidos;
>>   int           bytes_firma;
>>   EVP_MD_CTX    ctx;
>>   char          buf[TAM_BUF];
>>   int           err;
>>
>>   firma = (unsigned char *) malloc(EVP_PKEY_size(clave_EVP));
>>
>>   EVP_SignInit_ex(&ctx, EVP_md5(), NULL);
>>   while (!feof(fp_ext)){
>>     bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);
>>     EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);
>>   }//while
>>
>>   err = EVP_SignFinal(&ctx, firma, &bytes_firma, clave_EVP);m <-- in
>>    
>>
>this
>  
>
>>line occurs the error
>>   if (err != 1){
>>     ERR_print_errors_fp(stderr);
>>     exit (1);
>>   }//if
>>
>>   printf("Sign size is %s\n",bytes_firma);
>>    
>>
>
>you might try %d instead of %s ;-)
>
>Nils
>______________________________________________________________________
>OpenSSL Project                                 http://www.openssl.org
>User Support Mailing List                    [hidden email]
>Automated List Manager                           [hidden email]
>
>
>______________________________________________________________________
>OpenSSL Project                                 http://www.openssl.org
>User Support Mailing List                    [hidden email]
>Automated List Manager                           [hidden email]
>
>  
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: EVP_SignFinal third parameter type

Silvia Gisela Pavon Velasco
In reply to this post by Goetz Babin-Ebell




This solved the warning.
Thanks

Silvia G. Pavón V.
Procesos de Facturación
Alestra S.A.
Tel. 8748 6100 x4107


                                                                       
             Goetz Babin-Ebell                                        
             <goetz@shomitefo.                                        
             de>                                                        To
             Sent by:                  [hidden email]      
             owner-openssl-use                                          cc
             [hidden email]                                            
                                                                   Subject
                                       Re: EVP_SignFinal third parameter
             27/05/2005 08:01          type                            
             p.m.                                                      
                                                                       
                                                                       
             Please respond to                                        
             openssl-users@ope                                        
                 nssl.org                                              
                                                                       
                                                                       




Silvia Gisela Pavon Velasco wrote:
> Nils,
Hello Silvia,
> I changed to %d instead of %s it worked  =)
>
> But althougth I changed the declaration of the third argument to:
> unsigned int  *bytes_firma;
> I'm still getting the warning at compilation time.
>
> If I let:
> unsigned int  *bytes_firma;     and
> err = EVP_SignFinal(&ctx, firma, bytes_firma, clave_EVP);

the third parameter is an IO parameter:

unsigned int   bytes_firma = EVP_PKEY_size(clave_EVP);
unsigned char *firma       = malloc(bytes_firma);

[...]

err = EVP_SignFinal(&ctx,firma,&bytes_firma,clave_EVP);

[...]


Bye

Goetz

--
DMCA: The greed of the few outweighs the freedom of the many


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]