scd: pincache_put/pincache_get with AESWRAP with Padding (RFC-5649)
Open, NormalPublic

Assigned To
Authored By
• gniibe
Thu, Oct 15, 7:41 AM

Description

Currently, pincache_put and pincache_get uses AESWRAP (RFC 3394) with our own padding method.

BTW, there is a comment in the code:

/* FIXME: Replace this by OCB mode and use the cache key as
 * additional data.  */

But OCB is not an option, if we care about FIPS. So, I'd suggest removing this comment.

The code is a bit difficult, the NUL terminated requirement by pincache_get API (only returns a string which is assumed NUL terminated) is actually kept by pincache_put's adding padded zero and its pinbuflen calculation; By this handling, the decrypted pin has always one zero at the end at least, and more zeros if the pin length % 8 != 7. (when pin length % 8 == 0, it has 8 zeros.)

Let us clean up things here.

  • Use RFC-5649 AESWRAP with padding (it is implemented by libgcrypt already in 2022)
  • Fix pincache_get API so that it also returns pin length in r_pinlen

Event Timeline

• gniibe triaged this task as Normal priority.Thu, Oct 15, 7:41 AM
• gniibe created this task.
• gniibe created this object with edit policy "Contributor (Project)".
• gniibe added a project: scd.
• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Oct 19, 4:07 AM

For the first part, here is a patch:

Actually I have in mind a compliance=fips option also for gpg-agent to use a GCM variant for private key protection. But here we can indeed switch to AESWRAP with padding.

• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Oct 26, 3:32 AM