{"action":"created","issue":{"url":"https://api.github.com/repos/openssl/openssl/issues/1302","repository_url":"https://api.github.com/repos/openssl/openssl","labels_url":"https://api.github.com/repos/openssl/openssl/issues/1302/labels{/name}","comments_url":"https://api.github.com/repos/openssl/openssl/issues/1302/comments","events_url":"https://api.github.com/repos/openssl/openssl/issues/1302/events","html_url":"https://github.com/openssl/openssl/issues/1302","id":165047388,"number":1302,"title":"Strange behaviour of OpenSSL cms sign on large files","user":{"login":"ealloradai","id":448054,"avatar_url":"https://avatars.githubusercontent.com/u/448054?v=3","gravatar_id":"","url":"https://api.github.com/users/ealloradai","html_url":"https://github.com/ealloradai","followers_url":"https://api.github.com/users/ealloradai/followers","following_url":"https://api.github.com/users/ealloradai/following{/other_user}","gists_url":"https://api.github.com/users/ealloradai/gists{/gist_id}","starred_url":"https://api.github.com/users/ealloradai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ealloradai/subscriptions","organizations_url":"https://api.github.com/users/ealloradai/orgs","repos_url":"https://api.github.com/users/ealloradai/repos","events_url":"https://api.github.com/users/ealloradai/events{/privacy}","received_events_url":"https://api.github.com/users/ealloradai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-07-12T10:39:46Z","updated_at":"2016-07-15T12:10:20Z","closed_at":null,"body":"Hi All,\r\nHow is possible that the output of the signature a file bigger than 400MB using Openssl cms command is always 0 or some random size minor of 400MB?\r\n\r\nDoing some debug, I discovered that the issue is in the function named \r\nSMIME_crlf_copy in ASN1 module which contains this simple cycle\r\n\r\nwhile ((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0)\r\n          BIO_write(out, linebuf, len);\r\n\r\nIn my tests the number of reads is ok and match the file size, while the write operation are always lower. The result is a correctly signed CMS but the embedded signed content is truncated/partial.\r\n\r\nThis bug (?) happens only in Windows with Openssl from 2012 to 2016. Linux and MAC OSX are not affected.\r\n\r\nAm I doing something wrong? What is the correct way to sign a 1GB file using CMS envelope?"},"comment":{"url":"https://api.github.com/repos/openssl/openssl/issues/comments/232935751","html_url":"https://github.com/openssl/openssl/issues/1302#issuecomment-232935751","issue_url":"https://api.github.com/repos/openssl/openssl/issues/1302","id":232935751,"user":{"login":"ealloradai","id":448054,"avatar_url":"https://avatars.githubusercontent.com/u/448054?v=3","gravatar_id":"","url":"https://api.github.com/users/ealloradai","html_url":"https://github.com/ealloradai","followers_url":"https://api.github.com/users/ealloradai/followers","following_url":"https://api.github.com/users/ealloradai/following{/other_user}","gists_url":"https://api.github.com/users/ealloradai/gists{/gist_id}","starred_url":"https://api.github.com/users/ealloradai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ealloradai/subscriptions","organizations_url":"https://api.github.com/users/ealloradai/orgs","repos_url":"https://api.github.com/users/ealloradai/repos","events_url":"https://api.github.com/users/ealloradai/events{/privacy}","received_events_url":"https://api.github.com/users/ealloradai/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T12:10:20Z","updated_at":"2016-07-15T12:10:20Z","body":"Hi,\r\nThis is the version i'm using\r\n```\r\nC:\\OpenSSL-Win32\\bin>openssl.exe version -a\r\nOpenSSL 1.0.2h  3 May 2016\r\nbuilt on: reproducible build, date unspecified\r\nVC-WIN32\r\noptions:  bn(64,32) rc4(8x,mmx) des(idx,cisc,2,long) idea(int) blowfish(idx)\r\ncompiler: cl -D_USE_32BIT_TIME_T -D_USING_V110_SDK71_ -D_WINSOCK_DEPRECATED_NO_WARNINGS  /MD /Ox /O2 /Ob2 -DOPENSSL_THREADS  -DDSO_WIN32 -D_USE_32BIT_TIME_T -D\r\nUSING_V110_SDK71_ -D_WINSOCK_DEPRECATED_NO_WARNINGS -W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECAT\r\n -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_\r\nSM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DOPENSSL_USE_APPLINK -I. -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_SSL2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -\r\nOPENSSL_NO_WEAK_SSL_CIPHERS -DOPENSSL_NO_STATIC_ENGINE\r\nOPENSSLDIR: \"/usr/local/ssl\"\r\n```\r\n\r\nTest #1 sign a small file using CMS in binary mode OK\r\n`openssl cms -sign -binary -in openssl.cfg -out sss.p7m -signer pierino.crt -inkey pierino.key -nodetach -outform DER`\r\nFile in 11KB, File out 13 KB\r\n`openssl cms -verify -binary -CAfile TEST_CA.crt -in sss.p7m -inform DER`\r\nVerification successful\r\n\r\nTest #2 sign a large file using CMS in binary mode nodetach outform DER KO\r\n`openssl cms -sign -binary -in ubuntu-16.04-desktop-i386.iso -out sss.p7m -signer pierino.crt -inkey pierino.key -outform DER -nodetach`\r\nFile in 1.4GB, File out 464MB\r\n\r\nTest #3 sign a large file using CMS in binary mode nodetach KO\r\n`openssl cms -sign -binary -in ubuntu-16.04-desktop-i386.iso -out sss.p7m -signer pierino.crt -inkey pierino.key -nodetach`\r\nFile in 1.4GB, File out 629MB\r\n\r\nTest #4 sign a large file using CMS in binary mode KO\r\n`openssl cms -sign -binary -in ubuntu-16.04-desktop-i386.iso -out sss.p7m -signer pierino.crt -inkey pierino.key`\r\nFile in 1.4GB, File out 1.4GB + 3KB **<-----------SIZE IS OK** \r\n\r\n```\r\nC:\\OpenSSL-Win32\\bin>openssl cms -verify -binary -CAfile TEST_CA.crt -in sss.p7m -inform DER\r\nError reading S/MIME message\r\n2744:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:.\\crypto\\asn1\\tasn_dec.c:1197:\r\n2744:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:.\\crypto\\asn1\\tasn_dec.c:374:Type=CMS_ContentInfo\r\n\r\nC:\\OpenSSL-Win32\\bin>openssl cms -verify -binary -CAfile TEST_CA.crt -in sss.p7m\r\nError reading S/MIME message\r\n860:error:0D0D40D2:asn1 encoding routines:SMIME_read_ASN1:no multipart body failure:.\\crypto\\asn1\\asn_mime.c:457:\r\n```\r\n\r\nTest #5 sign a large file using CMS in binary mode outform DER KO\r\n`openssl cms -sign -binary -in ubuntu-16.04-desktop-i386.iso -out sss.p7m -signer pierino.crt -inkey pierino.key -outform DER`\r\nFile in 1.4GB, File out 2KB\r\n\r\n"}}
{"actor":{"display_login":"ealloradai"}}