HNHacker News
TopNewBestAskShowJobs

cryptbe

572 karma · joined September 18, 2010

submissionscomments
cryptbe··on So you want to roll your own crypto?
Author here, ask me anything.
cryptbe··on Crypto Vulnerabilities in AWS S3 SDK
The last vulnerability [1] is super cool, as it allows to decrypt AES-GCM ciphertexts using an AES-CBC padding oracle!

The exploit is very efficient and fits in a tweet:

1. Take C = E(K, IV) \xor P from GCM encryption

2. Make a guess of P, send (IV \ xor PADDING) || (C \xor P_guess) to the CBC oracle where PADDING is a fixed constant. If the oracle returns that the padding is correct, P_guess is correct. Otherwise make another guess.

The root cause of the issue runs pretty deep. It's a class of crypto vulnerabilities we called "in-band protocol negotiation". That is, the ciphertext contains protocol-related parameters that determine how it should be decrypted. The JWT standard has this issue, which has led to countless "alg": "none" vulnerabilities. JWT is not alone, this mistake is presented in many other libraries or standards.

I wrote about how we avoid this issue in Tink [2] [3]:

>2/ A key in Tink contains not only the raw key material, but also all necessary parameters. It is equivalent to the result of a handshake. Before any data encryption can take place, both sides have to reach an agreement not only on a raw key, but also how to use that key to encrypt data. Since a key in Tink contains all parameters, Tink does not require in-band ciphersuite negotiation. That is no ciphertext in Tink contains any other metadata aside from a key ID.

>This design sounds so simple but I've seen people get this wrong all the time. For example, the root cause of many embarrassing vulnerabilities in JWT [1] is in-band ciphersuite negotiation. That is, a JWT contains an alg field that dictates how the receiver should process it. This alg field should rather be included as part of the key.

>JWT is not the only standard making this mistake. Many crypto libraries only ask users for the raw key material. This means the parameters are either implicitly assumed or under specified. Aside from the aforementioned vulnerabilities, this can also lead to key confusion, cross-protocol key reuse and make it hard to rotate keys or change algorithms.

>To the best of my knowledge, Tink is the only high-level library that gets this right.

[1] https://github.com/google/security-research/security/advisor...

[2] https://github.com/google/tink

[3] https://news.ycombinator.com/item?id=23215652

cryptbe··on Tink – Cryptographic APIs that are secure, easy to use correctly
It's coming and will be part of 1.4.0: https://github.com/google/tink/issues/358.

We have a test package for Linux with Python 3.7 or 3.8

pip3 install -i https://test.pypi.org/simple/ tink

cryptbe··on Tink – Cryptographic APIs that are secure, easy to use correctly
Disclaimer: I'm a maintainer of Tink.

From a user's point of view, keys are still binary blob. Internally Tink serializes keys using protobuf, but in principle it supports arbitrary key formats via the KeysetReader/KeysetWriter interfaces. Admittedly, this aspect of our design is somewhat clumsy. We're working on a new design.

The key differences (pun intended) between Tink and other libraries are:

1/ Tink works with keysets instead of individual keys. This enables key rotation and crypto agility. This is very important at Google because there are systems that generate too much data to encrypt with a single key. We want to be able to rotate keys and still be able to decrypt old ciphertext.

Also most crypto schemes we're using today would be broken eventually. We want to make sure we can add new schemes and retire old ones over time without users having to change their code. For example, a lot of libraries have functions containing algorithm names, e.g., aes_gcm_encrypt. When GCM is no longer adequate, users of these libraries would have a hard time upgrading to alternatives.

Tink interfaces don't contain the algorithm name. We name our APIs after generic crypto primitives rather than famous cryptographers or algorithms. For example, we provide a generic AEAD interface for symmetric key encryption. With proper key management, users don't have to know anything about any particular algorithms and can easily rotate to new ones without changing a single line of code (rather than upgrading Tink).

2/ A key in Tink contains not only the raw key material, but also all necessary parameters. It is equivalent to the result of a handshake. Before any data encryption can take place, both sides have to reach an agreement not only on a raw key, but also how to use that key to encrypt data. Since a key in Tink contains all parameters, Tink does not require in-band ciphersuite negotiation. That is no ciphertext in Tink contains any other metadata aside from a key ID.

This design sounds so simple but I've seen people get this wrong all the time. For example, the root cause of many embarrassing vulnerabilities in JWT [1] is in-band ciphersuite negotiation. That is, a JWT contains an alg field that dictates how the receiver should process it. This alg field should rather be included as part of the key.

JWT is not the only standard making this mistake. Many crypto libraries only ask users for the raw key material. This means the parameters are either implicitly assumed or under specified. Aside from the aforementioned vulnerabilities, this can also lead to key confusion, cross-protocol key reuse and make it hard to rotate keys or change algorithms.

To the best of my knowledge, Tink is the only high-level library that gets this right.

[1] https://auth0.com/blog/critical-vulnerabilities-in-json-web-...

cryptbe··on Tink – Cryptographic APIs that are secure, easy to use correctly
Disclaimer: I'm one of the maintainers of Tink.

I'm not sure if NaCl itself is production ready, but I'm a great fan of libsodium. If I weren't working on Tink, I'd use libsodium for my personal projects. Did you know that Frank Denis [1] the creator of libsodium is not working full time on crypto or security? He's a professional photographer. I can't figure out how he manages to single-handedly maintain such a high-profile high-quality library as a side project. We have a team of full time cryptographers and engineers working on Tink, but we've struggled a lot.

We started Tink because all existing libraries that we had at Google didn't meet our requirements.

Business-wise, we need an open source library that can work on all major platforms that Google products run on including web, iOS, Android, Borg and GCP. There are many Google products that need crypto integration with external partners. While we can take care of the crypto implementation on our side, we found that many partners got it wrong. It'd be very nice if they can use the same library that we're using internally.

We learned very early that a single ciphersuite wouldn't work for everybody. Some would need short ciphertext. Some would need speed. Some would need FIPS certified. We want a library that can support a wide range of options. It should be easy to add new options and remove old ones.

Security-wise, we found that most libraries are either too high-level or too low.

The latter ask users for security-critical input such as nonces or randomness. In most crypto schemes, using a wrong kind of nonces can totally break an otherwise secure scheme. Based on our experience working with tens of thousands of engineers at Google, we found that most engineers can't tell why the IV must be non-repeated in some schemes but unpredictable in others. More importantly, we found that this level of control is not needed when using crypto to implement security/privacy features in most of our products. Tink aims to eliminate as many potential misuses as possible. For example, if the underlying encryption mode requires nonces and is insecure if nonces are reused, then Tink does not allow the passing of nonces by the user.

Why is too high-level also a bad idea? We found that many libraries provide a single API for different kinds of crypto primitive. For example, sign() is used for both MAC and digital signatures, and encrypt() for both AEAD and public key encryption. This reduces readability, making code review much harder because the crypto APIs can't provide accurate information on the security guarantees of the implementations.

Last but not least, Tink encourages the usage of key management system. Most libraries don't care where the keys come from, and as a result many users use hardcoded keys. Tink encourages developers to store keys encrypted or within a KMS. It provides security teams mechanisms to enforce this requirement. For example, at Google developers can't use Tink in production with keys stored outside our KMS, unless they got an explicit approval from us.

Further explanations of these design goals can be found in [2].

To wrap this up, IMHO libsodium and Tink are targeting different groups of audience. libsodium is great for personal projects, when you know what you're doing and can take care of yourself. Tink provides more bells and whistles which are useful when you want to do crypto in an enterprise setting.

[1] https://00f.net/

[2] https://github.com/google/tink/blob/master/docs/SECURITY-USA...

cryptbe··on Tink – Cryptographic APIs that are secure, easy to use correctly
Disclaimer: I'm a maintainer of Tink.

We've added tons of new features since 2018, including support for two new languages Golang and Python.

The team has grown from 4 20% contributors to 5 full-time and countless contributors.

Please checkout the following release notes for a list of changes:

https://github.com/google/tink/releases/tag/v1.3.0

https://github.com/google/tink/releases/tag/v1.4.0-rc1

cryptbe··on Vietnam's contact tracing app broadcasting a fixed ID
In less than a week, 77K people have installed the app, according to the official tally published by the developer.

The growth rate is 2x-3x every day, faster than COVID-19.

cryptbe··on Vietnam's contact tracing app broadcasting a fixed ID
Thanks, appreciate it! Check out this comment: https://news.ycombinator.com/item?id=22991028.
cryptbe··on Vietnam's contact tracing app broadcasting a fixed ID
Author here. One interesting aspect that I've learned is the tactics, techniques, and procedures (TTPs) of public opinion brigades, aka Force 47.

They tried hard to discrete me. My initial report had an error, that is I didn't know that Bluetooth on Android needs ACCESS_FINE_LOCATION permission. A person pointed this out in a comment -- he posted and rewrote it three times. I said thank you and thought that's that, but then he and a bunch of new people commented that since I made that basic mistake I'm immature and inexperienced, therefore the rest of my findings have no merit.

Someone then posted a super long comment, raising a lot of questions about my credibility and intention. The interesting thing is they claimed that they're a student, haven't installed the app, have no intention to do so, but care a lot about privacy. Essentially they want to show that they're merely an underdog bystander standing up against my wrongdoings. I thought this is a very subtle psychological trick, aiming to amplify their attacks.

Other attacks are more direct. For example, a person pointed out that since I don't have many followers on Twitter, I'm not a good engineer. They said I didn't really contribute anything to my public research, but I just took credit from my coauthors. That I am only cleaning toilet at Google, there's nothing proud about that.

After I posted a rebuttal to the developers' rebuttal, a guy [2] dropped this one-line comment:

>cái vụ này bắt đầu thấy nhảm rồi. Lập luận của anh Thái cũng không còn chặt chẽ như trước nữa.

Which translates to "This is getting nonsense. Thai's argument is not as strict as before".

The title of the guy's blog [3] is, I kid you not, "There's always only one truth: Communist Party of Vietnam.

[1] https://en.wikipedia.org/wiki/Public_opinion_brigades

[2] https://www.blogger.com/profile/17567201928186857755

[3] http://phichnuocnong.blogspot.com/

cryptbe··on Vietnam's contact tracing app broadcasting a fixed ID
Thanks.

I have no strong evidence, but it seems that Force 47 is actively monitoring my blog [1]. I've never got so many personal attacks and smear comments like I did since I published my findings. I bet one of them will cite your comment as an evidence of my "immaturity".

[1] https://en.wikipedia.org/wiki/Public_opinion_brigades

cryptbe··on Vietnam's contact tracing app broadcasting a fixed ID
I wrote the article. I agreed. It's a bad joke. I have no intention causing harm to this system.
cryptbe··on A Graduate Course in Applied Cryptography
It's https://vnhacker.blogspot.com. I rarely blog in English. However, right now there's a pretty good post: https://vnhacker.blogspot.com/2020/04/vietnams-contact-traci....
cryptbe··on A Graduate Course in Applied Cryptography
Yes, it did. I'm doing crypto at Google.
cryptbe··on A Graduate Course in Applied Cryptography
DH was invented at Stanford.

RSA was allegedly invented at GCHQ.

cryptbe··on A Graduate Course in Applied Cryptography
This is hands down the best book on applied crypto, especially for people who want to self-learn crypto. I started reading it since version 0.1, but every time I pick it up I learn something new.The fun application section in each chapter is pure gold. The exercises are challenging but super rewarding. I can't do many of them, but reading the problem statements is usually enough to make me realize I don't understand something.

When I started learning crypto, I spent a lot of time reading A Computational Introduction to Number Theory and Algebra [1] another free, high-quality book by Shoup. I did a lot of exercises, even corrected some results in the book, and at one point thought that I wanted to publish a solution manual. I emailed professor Shoup, but he said it may not be a good idea because people would copy my solutions for their homework. It turns out he's right. The blog posts that I published still get hit from time to time, and the search keyword is always solutions for NTB [2] =).

Later on, I took CS255 [3] from Boneh. I had to pay for it myself. IIRC it was $4,000 or something. It was a huge amount of money where I'm from. I took an overdraft from my bank to pay for it, the best money I ever spent! I still remember in one of the classes when Boneh was talking about the Diffie-Hellman protocol he paused to ask us, "Do you know where this was invented?" Nobody knows, then he pointed to his left and said, "In a room a few yards from here". I felt like I was part of this amazing history. There's a stream of knowledge flowing through me and maybe one day I'd discover something cool.

Boneh is simply the best teacher. He knows everything. I like it when he poses an open problem, and ends with "if you can solve this, I'll be a friend forever". He doesn't just love teaching, but also knows how to inspire and apparently can't stop explaining things.

[1] https://www.shoup.net/ntb/

[2] https://www.google.com/search?rlz=1C5CHFA_enUS851US851&ei=z0...

[3] https://crypto.stanford.edu/~dabo/cs255/

cryptbe··on AES-based Synthetic IDs: deterministic AE for 64-bit integers
Haha I came here to ask the same question.

This "SIV" mode is silly and breaks down completely when encrypting more than 2^32 IDs.

Your proposal is not only faster, but also safer. AES is a strong pseudorandom permutation, the 00000000 padding is a perfectly fine integrity check.

cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
>It is, but some libraries do not perform this check. Including TweetNaCl if I recall correctly.

I'm not sure why TweetNaCl is even considered a serious crypto library. I guess that it can fit in tweets, but this is an optimization that is at best irrelevant at worst a bad software engineering practice.

Re malleability: instead of just thinking about this issue in an abstract way, I recommend writing an exploit. For example, Tink doesn't check R or A at all, try to see if you can produce a new signature from an existing one by modifying R or A as you said.

cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
You should not implement Ristretto, and continue implementing stuff that you're comfortable with.

Crypto is deep. You can get involved at the levels you feel comfortable with.

cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
If one implements EdDSA, but does not follow RFC 8032, one is doing it wrong on multiple levels.
cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
I didn't say anything about gatekeeping. It's okay to make mistakes, that's one of the best way to learn.

I said if one isn't comfortable with the math, maybe don't try to roll one's own crypto and advertise or use it as production-grade crypto.

cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
>Ristretto is nice, terribly complex, and you don't actually need to care about the conceptual complexity. As an implementer, your only job is to execute the explicit formulas in section 5 of the Ristretto website. You do not have to be able to follow the hard math (just how you do not have to be able to follow the hard math involved in making the explicit formulas).

I don't think one should blindly follow an instruction without understanding why in any fields, let alone in crypto where a small, subtle difference can make or break it. Also, understanding crypto requires less math than inventing (and attacking) crypto, so it takes some effort, but it's doable even for hobbyists. If the math makes one uncomfortable, maybe one shouldn't try to roll their own crypto for production use in the first place.

Case in point: the author of this article that we're commenting on made a deadly mistake because they did not understand the math behind point conversion between Ed25519 and Curve25519 [1].

Below I also point out a mistake in their claim about malleability in EdDSA.

[1] https://www.reddit.com/r/crypto/comments/8toywt/critical_vul...

cryptbe··on Cofactor Explained: Clearing Elliptic Curves' dirty little secret
tl;dr: the conclusion of the EdDSA part of the article is wrong. EdDSA has its problems, but malleability is not one of them, if one is following RFC 8032.

>There are several ways to sign a document with EdDSA, and produce a valid signature. The three sources of malleability are:

>We can add a multiple of L (the order of the prime subgroup) to s. Recall that B has order L as well, so it will absorb any cofactor. Basically everything happens modulo L, so adding L won't change a thing.

This is prevented in RFC 8032 by checking that 0 <= s < L. Tink [1] does this check, and therefore is malleability free.

>We can sign the same message with a different nonce r. This requires knowledge of the secret key a.

This proves that the signature of a message is not unique -- that is the signer can product multiple signatures -- but I haven't seen anyone calling this a malleability issue. Malleability is about taking a triple (public key, signature message) and tweaking bits to produce another valid triple.

>We can add a low order point to A, and subtract it from R. That way we produce a valid signature, but from a public key nobody vouches for. If the verifier checks the weaker equation, we can add a low order point to just R, and produce a "valid" signature with the same public key.

This is the second time I saw this claim. When I first saw it [2], I thought, wait, this test is missing in Wycheproof [3], but Bleichenbacher does NOT miss anything. That's when I knew it's wrong.

Modifying A or R instantly makes the signature invalid. Using the article's notation, the signature is validated by checking that

B.s.8 == R.8 + A.h.8, where h = SHA-512(R, A, M) and M is the message

Multiplying the cofactor or not doesn't matter, doesn't introduce any weakness, as implied by the article. If R or A is changed, h will change.

[1] https://github.com/google/tink

[2] https://github.com/dalek-cryptography/ed25519-dalek/issues/2...

[3] https://github.com/google/wycheproof. Wycheproof has tests for EdDSA malleability, but it only tests if s is not properly range checked.

cryptbe··on Why I Quit Google to Work for Myself
At Google you can ask your coworkers to write feedback that would be included in your promo package. I wonder why the author didn't ask the developers that they helped to write a few sentences explaining how much time they'd saved thanks to the author's help. The hiring committee wouldn't ask for any metric if there were already a few people testifying that "I saved XX hours".

Disclaimer: I work at Google.

cryptbe··on The Matasano Crypto Challenges (2013)
<shameless plug>

If you enjoy these challenges you might want to join my team at Google, to analyze, break, design and implement real-world crypto solutions for products used by billions of people.

Aside from short-term projects like analyzing and improving state-of-the-art password hashing or end-to-end encryption schemes, we've started two long-term that could use your help: Wycheproof [1] and Tink [2]. The former is a revolutionary testing framework that has discovered 40+ bugs [1] in many popular crypto libraries. The later provides a safe, simple, agile and fast way to accomplish common crypto tasks.

If this sounds exciting, please send your resumes to thaidn@google.com. Cheers!

[1] https://github.com/google/wycheproof

[2] https://github.com/google/tink

[3] https://github.com/google/wycheproof/blob/master/doc/bugs.md

</shameless plug>

cryptbe··on Google Search King Amit Singhal Retiring
You meant Matt Cutts? He's still at Google, isn't he?
cryptbe··on Exploiting the Diffie-Hellman bug in socat
Because generating p on the fly is expensive. On the other hand, using a safe prime is fine, even if it was generated by a third party.
cryptbe··on DANE is a protocol that enables verified TLS connections without CAs
Crypto as I know it doesn't allow performing an authenticated key exchange between two entities without neither a pre-shared secret nor a trusted third party (CA) [1]. Anyone who promises anything like that is either selling snake-oil or hiding some requirement. DANE still requires trusted third parties, I'm not sure why it's better than the current model.

[1] There's https://en.wikipedia.org/wiki/Merkle%27s_Puzzles, but it's not really practical when you make it secure and not secure when you make it practical.

cryptbe··on Same Origin Method Execution (SOME)
Prior art: https://plus.sandbox.google.com/+AleksandrDobkin-Google/post....
cryptbe··on Slack was hacked
> 3. For some historical reasons, many people feel the need to change keys regularly. This is rather misguided: key rotation makes sense in an army or spy network where there are many keys, and partial compromissions are the normal and expected situation, so a spy network must, by necessity, be in permanent self-cleansing recovery mode; when there is a single key and the normal situation is that the key is NOT compromised, changing it brings no tangible advantage.

This is a really strange advice from Thomas Pornin. People rotate keys because not doing so weakens most symmetric encryption schemes. For example while using AES-GCM with 96-bit nonces one needs to rotate keys after encrypting roughly 2^32 ~ 4 billion messages; otherwise the IV collision probability will be higher than 2^(-32), which is already high enough in most large scale systems (and really bad things happen when the IV is repeated).

cryptbe··on Google Vietnam Compromised?
While I'm not 100% sure, it's likely that VNNIC has been 0wned.

Rationale: VNNIC doesn't provide any online DNS management tools. One has to submit a paper request in person to change any DNS records.

Edit: it looks like it's the registrar WebNic.cc that got hacked.

← PreviousPage 2 of 4Next →