Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • shell command (openssl aes256) sometimes returns an error

    Hi, this is puzzling me. I am using -shell- or ! to encrypt and decrypt files en masse with openssl, on Mac OSX El Capitan with Stata 14.2/SE. I might have a line like this:
    Code:
    ! openssl enc -aes256 -in "./folder/data.xlsx" -out "./folder/data.xlsx.enc" -k thepassword
    to encrypt, and this:
    Code:
    ! openssl aes256 -d -in "./folder/data.xlsx.enc" -out "./folder/data.xlsx" -k thepassword
    to decrypt. In each case, if I paste the same line (minus the !) into the terminal, it runs just fine. But from Stata, the first line runs and the second one returns an error:
    openssl:Error: 'aes256' is an invalid command.
    This is an error issued by openssl from the looks of it, and aes256 is a valid command for openssl (as shown by the way it runs in the terminal), so it seems to me that something odd is happening to the command on its way out of Stata. Does this ring any bells for anyone? Have I done something really silly that I just can't see?

    Robert



  • #2
    I tracked it down. There are two versions of openssl on this computer, one in an anaconda environment and one presumably on the loose in the OS somewhere that I can't easily see. Specify the anaconda path and I get a consistent version.

    Comment


    • #3
      Robert Grant

      I think you might have something customized in your local configuration:

      Code:
      billy:Stata billy$ openssl help
      openssl:Error: 'help' is an invalid command.
      
      Standard commands
      asn1parse         ca                ciphers           cms               
      crl               crl2pkcs7         dgst              dh                
      dhparam           dsa               dsaparam          ec                
      ecparam           enc               engine            errstr            
      gendh             gendsa            genpkey           genrsa            
      nseq              ocsp              passwd            pkcs12            
      pkcs7             pkcs8             pkey              pkeyparam         
      pkeyutl           prime             rand              req               
      rsa               rsautl            s_client          s_server          
      s_time            sess_id           smime             speed             
      spkac             srp               ts                verify            
      version           x509              
      
      Message Digest commands (see the `dgst' command for more details)
      md4               md5               mdc2              rmd160            
      sha               sha1              
      
      Cipher commands (see the `enc' command for more details)
      aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb       
      aes-256-cbc       aes-256-ecb       base64            bf                
      bf-cbc            bf-cfb            bf-ecb            bf-ofb            
      camellia-128-cbc  camellia-128-ecb  camellia-192-cbc  camellia-192-ecb  
      camellia-256-cbc  camellia-256-ecb  cast              cast-cbc          
      cast5-cbc         cast5-cfb         cast5-ecb         cast5-ofb         
      des               des-cbc           des-cfb           des-ecb           
      des-ede           des-ede-cbc       des-ede-cfb       des-ede-ofb       
      des-ede3          des-ede3-cbc      des-ede3-cfb      des-ede3-ofb      
      des-ofb           des3              desx              idea              
      idea-cbc          idea-cfb          idea-ecb          idea-ofb          
      rc2               rc2-40-cbc        rc2-64-cbc        rc2-cbc           
      rc2-cfb           rc2-ecb           rc2-ofb           rc4               
      rc4-40            seed              seed-cbc          seed-cfb          
      seed-ecb          seed-ofb
      It looks like aes256 and/or other types of encryption/decryption algorithms are subcommands for enc. Seems strange that the second command works in your terminal, but wasn't sure if maybe it was something with the way you have the installation and/or terminal configured.

      Comment


      • #4
        Hi Billy. It seems aes256 wasn't in the cipher commands version 0.x of openssl, instead (like in your output), you had to specify aes-256-cbc or -ecb -- but only on decrypt, weirdly, because enc -aes256 is OK! version 0.x seems to get shipped with OSX. These little things can cause so much disruption!

        Comment


        • #5
          Robert Grant The help from the version I printed above is a bit later
          Code:
          OpenSSL 1.0.2k  26 Jan 2017
          but I definitely agree that there are a lot of random issues that can creep up like that (especially if you've installed other versions via Homebrew, MacPorts, Fink, etc...).

          Comment

          Working...
          X