Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
1–10 of 76 posts
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#2Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#3Hm. I wrote this for our normal blog readers, who live and breathe security stuff, so I don't know how well it'll carry here.
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#4A question to start up founders: How do you guys handle security? Do you hire consultants/pen-testers? Do you just copy+paste code from the internet? Do you use whatever framework's components for it?
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#5I assume my hash comparison function is constant time (eg. XOR(a[x],b[x])==0), rather than comparing of char-by-char.
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#6Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#7Hm. I wrote this for our normal blog readers, who live and breathe security stuff, so I don't know how well it'll carry here.
Definitely an interesting read even for crypto dilettantes. Perhaps, especially for crypto dilettantes.
I took Rivest's Computer and Network Security class in college and the most important takeaway for me, far outstripping all of the interesting technical content, was "Don't implement crypto."
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#8Set up an encryptor:
irb> e = OpenSSL::Cipher::Cipher.new('aes-256-ofb')
=> #
irb> e.key = "\x11" * 32
irb> e.iv = "\x00" * 16
A decryptor: irb> d = OpenSSL::Cipher::Cipher.new('aes-256-ofb')
=> #
irb> d.decrypt
irb> d.key = "\x11" * 32
irb> d.iv = "\x00" * 16
Encrypt something: irb> ciphertext = (e "a\255N\211XEn\001\347$\275)\311%Ht\2356\254m\b\234z\375\311\006\335\305F\231~\201\243\236\3628w\267\3454"
Make an XOR mask: irb> mask = ("187 she wrote".to_bignum ^ ("A" * 13).to_bignum).to_rawstring
=> "pyva2)$a63.5$"
XOR it into the ciphertext: irb> new_ciphertext = (ciphertext.to_bignum ^ mask.to_bignum).to_rawstring
NOW decrypt it: irb> d "AAAAAAAAAAAAAAAAAAAAAAAAAAA187 she wrote"Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#9So, is there much to be gained from encryption anyway? If, as the candidate, I suggested sending a cookie as 'userId=39493&role=user×tamp=1414919&hash= ' then would I lose brownie points? I assume my hash comparison function is constant time (eg. XOR(a[x],b[x])==0), rather than comparing of char-by-char.
Often you don't need confidentiality, and in those cases, HMAC can be a safer bet than a secure encrypted message format. You want to use HMAC though, not a simple hash with a secret key in it.
Re: Typing The Letters A-E-S Into Your Code? You’re Doing It Wrong
#10Hm. I wrote this for our normal blog readers, who live and breathe security stuff, so I don't know how well it'll carry here.
You blogged the shit outta that post! Definitely an interesting read even for crypto dilettantes. Perhaps, especially for crypto dilettantes. I took Rivest's Computer and Network Security class in college and the most important takeaway for me, far outstripping all of the interesting technical content, was "Don't implement crypto."