Skip to content

File decryption fails (wrong final block length) on Windows #4746

@lukeIam

Description

@lukeIam

Decrypting my file fails with bad decrypt: wrong final block length.

I used travis encrypt-file file under Windows to encrypt my file without problems.
Also I added the generated decryption command to the before_install: section:

openssl aes-256-cbc -K $encrypted_048ea30036f2_key -iv $encrypted_048ea30036f2_iv -in file.enc -out file -d

(Also tried the --add option of travis encrypt-file)

Here are parts of the build log:

[...]
$ export encrypted_048ea30036f2_key=[secure]
$ export encrypted_048ea30036f2_iv=[secure]
[...]
$ openssl aes-256-cbc -K $encrypted_048ea30036f2_key -iv $encrypted_048ea30036f2_iv -in file.enc -out file -d
bad decrypt
139709116544672:error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length:evp_enc.c:532:
The command "openssl aes-256-cbc -K $encrypted_048ea30036f2_key -iv $encrypted_048ea30036f2_iv -in file.enc -out file -d" failed and exited with 1 during .
Your build has been stopped.

Any suggestions?

Activity

BanzaiMan

BanzaiMan commented on Sep 3, 2015

@BanzaiMan
Contributor

Could you try steps with travis encrypt-file -r OWNER/REPO file?

lukeIam

lukeIam commented on Sep 3, 2015

@lukeIam
Author

sure - but got the same problem with the same message

Some more information about the project:
we need a new build system so I'm trying out Travis CI.
-> the .travis.yml only exists in a brach travisTest in my fork lukeIam/Vocaluxe.
Travis is enabled for this fork and was successfully building, before I added the encrypted file.
The log of the last build can be found here:
https://travis-ci.org/lukeIam/Vocaluxe/builds/78612690

BanzaiMan

BanzaiMan commented on Sep 4, 2015

@BanzaiMan
Contributor

I just remembered. You cannot encrypt more than 1 file, because the second invocation nullifies the first. This is documented. http://docs.travis-ci.com/user/encrypting-files/#Encrypting-multiple-files

lukeIam

lukeIam commented on Sep 4, 2015

@lukeIam
Author

@BanzaiMan Thanks for your time! But I'm afraid I don't get it...

"You cannot encrypt more than 1 file" - I knew this and I've only encrypted a single file and of course I have only one openssl line in my .travis.yml.

The other key/iv pair was from the last attempt and is now deleted.
build log

Or does does the secure line of the deploy section (github releases), consumes the single possible openssl call, even it does't use a file?

BanzaiMan

BanzaiMan commented on Sep 4, 2015

@BanzaiMan
Contributor

@lukeIam In the build you indicated, I see 2 sets of environment variables set by travis encrypt-file … command (https://travis-ci.org/lukeIam/Vocaluxe/builds/78612690#L935-L938) This indicates to me that you ran the command twice, and you added those in your repository's settings.

In https://travis-ci.org/lukeIam/Vocaluxe/builds/78738939, I see that you've removed one, but perhaps you removed the wrong one.

lukeIam

lukeIam commented on Sep 4, 2015

@lukeIam
Author

@BanzaiMan

In https://travis-ci.org/lukeIam/Vocaluxe/builds/78738939, I see that you've removed one, but perhaps you removed the wrong one.

I removed all four variables with travis env unset [...] and reran travis encrypt-file.
It recreated $encrypted_a377c9765acb (same variable name).

I started an other try and got the same variable again.
Here is what I executed:

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

D:\Projects\Vocaluxe>travis env list
# environment variables for lukeIam/Vocaluxe
encrypted_a377c9765acb_key=[secure]
encrypted_a377c9765acb_iv=[secure]

D:\Projects\Vocaluxe>travis env unset encrypted_a377c9765acb_key
[x] removing environment variable $encrypted_a377c9765acb_key

D:\Projects\Vocaluxe>travis env unset encrypted_a377c9765acb_iv
[x] removing environment variable $encrypted_a377c9765acb_iv

D:\Projects\Vocaluxe>travis env list
# environment variables for lukeIam/Vocaluxe

D:\Projects\Vocaluxe>travis whoami
You are lukeIam

D:\Projects\Vocaluxe>travis encrypt-file -r lukeIam/Vocaluxe travisKey
encrypting travisKey for lukeIam/Vocaluxe
storing result as travisKey.enc
storing secure env variables for decryption

Please add the following to your build script (before_install stage in your .tra
vis.yml, for instance):

    openssl aes-256-cbc -K $encrypted_a377c9765acb_key -iv $encrypted_a377c9765a
cb_iv -in travisKey.enc -out travisKey -d

Pro Tip: You can add it automatically by running with --add.

Make sure to add travisKey.enc to the git repository.
Make sure not to add travisKey to the git repository.
Commit all changes to your .travis.yml.

D:\Projects\Vocaluxe>
BanzaiMan

BanzaiMan commented on Sep 4, 2015

@BanzaiMan
Contributor

Hmmm. Interesting. Do you have access to another OS (Linux or Mac)? Does this happen there, too?

lukeIam

lukeIam commented on Sep 4, 2015

@lukeIam
Author

I'll install a linux...

cotsog

cotsog commented on Sep 4, 2015

@cotsog

Maybe related: we had a report of a user not able to encrypt env variables on Windows.

lukeIam

lukeIam commented on Sep 4, 2015

@lukeIam
Author

On ubuntu 14.04 LTS x64 it worked:
https://travis-ci.org/lukeIam/Vocaluxe/builds/78758729
(The build faild, but this is caused by my deploy script - openssl is working!)

travis encrypt-file generated a new variable with linux

changed the title [-]File decryption fails (wrong final block length)[/-] [+]File decryption fails (wrong final block length) on Windows[/+] on Sep 4, 2015
MariadeAnton

MariadeAnton commented on Sep 4, 2015

@MariadeAnton

related to @cotsog - it was failing in a Windows 8 machine, using the default Command Prompt and ConEmu x64

16 remaining items

TomeOkin

TomeOkin commented on Apr 17, 2016

@TomeOkin

I also meet the problem:
The command "openssl aes-256-cbc -K $encrypted_e59b7992228b_key -iv $encrypted_e59b7992228b_iv -in jo.jks.enc -out jo.jks -d" failed and exited with 1 during .

I has try cmd and git shell in win7, but get the same result.

suriyaa

suriyaa commented on Apr 17, 2016

@suriyaa

Got the same problem: https://travis-ci.org/iSCInc/status/builds/123697131! I use Windows 10 - Git Bash, CMD & Powershell.

seayxu

seayxu commented on Apr 17, 2016

@seayxu

@TomeOkin @SuriyaaKudoIsc if you don't want to use Linux system,just see this way;I found the reason for this problem is that the Travis encryption generation variable is different from the Linux system in the windows system.So,I suggest you use Linux system do this.

suriyaa

suriyaa commented on Apr 17, 2016

@suriyaa

@seayxu Well... 😅 I can't speak or read in Chinese.

seayxu

seayxu commented on Apr 17, 2016

@seayxu
MikeJerred

MikeJerred commented on Apr 21, 2016

@MikeJerred

+1 Using Windows 8.1 here and got the same error. Encrypting the file on linux (using Google Cloud Shell) works fine

snowdream

snowdream commented on Jun 12, 2016

@snowdream

This is also happenning on Windows 7 x64 with Git Bash command prompt.

trashier

trashier commented on Jun 29, 2016

@trashier

This issue still occurs.

nawazdhandala

nawazdhandala commented on Aug 2, 2016

@nawazdhandala

+1

Jameskmonger

Jameskmonger commented on Aug 3, 2016

@Jameskmonger

Still experiencing this on Windows.

Bosek

Bosek commented on Aug 6, 2016

@Bosek

+1 Win10

locked and limited conversation to collaborators on Aug 6, 2016
added
lockedThis thread is locked, and won't automatically be closed
on Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lockedThis thread is locked, and won't automatically be closedwindows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bterlson@BanzaiMan@cotsog@nickvandewiele@waltertamboer

        Issue actions

          File decryption fails (wrong final block length) on Windows · Issue #4746 · travis-ci/travis-ci