Assume I have a 40 bytes hexadecimal ASCII string and a 50 bytes random password.

data: a7cd8558a341e3525d060e90fb37975efa8dd519
key:  ]*Úf"¢^¨¥GJþPÒYÅ9ÝÁ´!½OïæñÝ{/§@·]%¾âðNQn@:U2çþÇ<uÓ

The data will be AES256 encrypted with the password. The encrypted data will be stored as a key-value pair and that key and the usage of it predicts the decrypted data represents a lower case 40 bytes hex value.


What can I assume how secure the encrypted data will be?

Use case scenario

I'm using Ansible to provision my VM. One of the Ansible scripts uses my GitHub API token. The token is stored as an variable encrypted with AES256 by the Ansible Vault.

Now I'd like to store my Ansible scripts in my GitHub repository. But I'm not sure how much does it cost to decrypt the GitHub API token.


1 Answer 1


For reference, this is the Ansible Vault format. In short:

  • It derives an AES key, HMAC key and IV from the password using a 32-byte random salt
  • It encrypts the data using AES-CTR with the derived key and IV
  • It MACs the ciphertext (but not the IV) with HMAC-SHA256. Not including the IV is usually bad, but since the IV is derived from the password and salt and it's not stored with encrypted data, it seems OK.

As far as I know, this looks safe if the password is strong enough. In your case, what you call "key" seems to be the password, and is certainly long enough.

  • $\begingroup$ I edited my question to fix the usage of key and password. $\endgroup$
    – codekandis
    Jul 26, 2019 at 16:08
  • $\begingroup$ Is there an issue while the assumed decrypted data can be predicted to [0-9a-f] per byte by a length of 40 bytes ? $\endgroup$
    – codekandis
    Jul 26, 2019 at 16:39
  • $\begingroup$ @codekandis you think someone can guess 200 bits of entropy correctly? $\endgroup$ Jul 26, 2019 at 17:32
  • 1
    $\begingroup$ @codekandis no, proper cryptographic algorithms don't care about what kind of content is being encrypted. $\endgroup$
    – Conrado
    Jul 26, 2019 at 17:33
  • 2
    $\begingroup$ @codekandis nope, the nature/range of cleartext doesn't matter for AES. All an attacker can do is brute-force, i.e. try 2^128 keys on average. $\endgroup$
    – tum_
    Jul 26, 2019 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.