Mageia Bugzilla – Attachment 12932 Details for
Bug 29467
libgcrypt new security issue CVE-2021-40528
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
A basic c program calling the library
arcfour.c (text/x-csrc), 2.72 KB, created by
Brian Rockwell
on 2021-09-24 03:52:47 CEST
(
hide
)
Description:
A basic c program calling the library
Filename:
MIME Type:
Creator:
Brian Rockwell
Created:
2021-09-24 03:52:47 CEST
Size:
2.72 KB
patch
obsolete
>#include <stdio.h> >#include <gcrypt.h> >#include <assert.h> > >int main() >{ > > gcry_cipher_hd_t handle; > gcry_cipher_hd_t handle2; > gcry_error_t err = 0; > char * plain_text ; > char * out ; > char * deout ; > > plain_text = ( char * ) malloc ( sizeof ( char ) * ( 6 ) ); > out = ( char * ) malloc ( sizeof ( char ) * ( 60 + 1 ) ); > deout = ( char * ) malloc ( sizeof ( char ) * ( 60 + 1 ) ); > assert ( plain_text ); > assert ( out ); > assert ( deout ); > > strcpy ( plain_text , "SecretMessage" ); > > printf ( "%d %d \n", ( int ) sizeof ( plain_text ), strlen ( plain_text ) ); > gcry_check_version ( NULL ); > gcry_control ( GCRYCTL_DISABLE_SECMEM_WARN ); > gcry_control ( GCRYCTL_INIT_SECMEM, 16384, 0 ); > > > { > > err = gcry_cipher_open ( &handle2, GCRY_CIPHER_ARCFOUR,GCRY_CIPHER_MODE_STREAM,0 ); > err = gcry_cipher_open ( &handle, GCRY_CIPHER_ARCFOUR,GCRY_CIPHER_MODE_STREAM,0 ); > > if ( err ) > { > fprintf ( stderr, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > fprintf ( stdout, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > > } > err = gcry_cipher_setkey ( handle, "This is really strange , i read the documentation i googled for two days and nothing , i can't encrypt && decrypt",256 ); > err = gcry_cipher_setkey ( handle2, "This is really strange , i read the documentation i googled for two days and nothing , i can't encrypt && decrypt",256 ); > if ( err ) > { > fprintf ( stderr, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > fprintf ( stdout, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > > } > } > err = gcry_cipher_encrypt ( handle, > ( unsigned char * ) out, sizeof ( out ), ( const unsigned char * ) plain_text,sizeof plain_text ); > if ( err ) > { > fprintf ( stderr, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > fprintf ( stdout, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > > } > printf ( " out :%s ||| plain text %s\n",out, plain_text ); > err = gcry_cipher_encrypt ( handle2, > ( unsigned char * ) deout, sizeof deout, ( const unsigned char * ) out,sizeof out ); > if ( err ) > { > fprintf ( stderr, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > fprintf ( stdout, "Failure: %s/%s\n", > gcry_strsource ( err ), > gcry_strerror ( err ) ); > > } > printf ( "deout: %s ||| out: %s ||| plain text: %s\n",deout, out,plain_text ); > > free ( plain_text ); > free ( out ); > free ( deout ); > gcry_cipher_close ( handle ); > gcry_cipher_close ( handle2 ); > return 0; > >}
#include <stdio.h> #include <gcrypt.h> #include <assert.h> int main() { gcry_cipher_hd_t handle; gcry_cipher_hd_t handle2; gcry_error_t err = 0; char * plain_text ; char * out ; char * deout ; plain_text = ( char * ) malloc ( sizeof ( char ) * ( 6 ) ); out = ( char * ) malloc ( sizeof ( char ) * ( 60 + 1 ) ); deout = ( char * ) malloc ( sizeof ( char ) * ( 60 + 1 ) ); assert ( plain_text ); assert ( out ); assert ( deout ); strcpy ( plain_text , "SecretMessage" ); printf ( "%d %d \n", ( int ) sizeof ( plain_text ), strlen ( plain_text ) ); gcry_check_version ( NULL ); gcry_control ( GCRYCTL_DISABLE_SECMEM_WARN ); gcry_control ( GCRYCTL_INIT_SECMEM, 16384, 0 ); { err = gcry_cipher_open ( &handle2, GCRY_CIPHER_ARCFOUR,GCRY_CIPHER_MODE_STREAM,0 ); err = gcry_cipher_open ( &handle, GCRY_CIPHER_ARCFOUR,GCRY_CIPHER_MODE_STREAM,0 ); if ( err ) { fprintf ( stderr, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); fprintf ( stdout, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); } err = gcry_cipher_setkey ( handle, "This is really strange , i read the documentation i googled for two days and nothing , i can't encrypt && decrypt",256 ); err = gcry_cipher_setkey ( handle2, "This is really strange , i read the documentation i googled for two days and nothing , i can't encrypt && decrypt",256 ); if ( err ) { fprintf ( stderr, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); fprintf ( stdout, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); } } err = gcry_cipher_encrypt ( handle, ( unsigned char * ) out, sizeof ( out ), ( const unsigned char * ) plain_text,sizeof plain_text ); if ( err ) { fprintf ( stderr, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); fprintf ( stdout, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); } printf ( " out :%s ||| plain text %s\n",out, plain_text ); err = gcry_cipher_encrypt ( handle2, ( unsigned char * ) deout, sizeof deout, ( const unsigned char * ) out,sizeof out ); if ( err ) { fprintf ( stderr, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); fprintf ( stdout, "Failure: %s/%s\n", gcry_strsource ( err ), gcry_strerror ( err ) ); } printf ( "deout: %s ||| out: %s ||| plain text: %s\n",deout, out,plain_text ); free ( plain_text ); free ( out ); free ( deout ); gcry_cipher_close ( handle ); gcry_cipher_close ( handle2 ); return 0; }
View Attachment As Raw
Actions:
View
Attachments on
bug 29467
: 12932