ietf-openpgp
[Top] [All Lists]

Re: [openpgp] v5 Secret-Key Packet Formats

2018-01-22 03:25:39
On Sat, 20 Jan 2018 00:08, sandals(_at_)crustytoothpaste(_dot_)net said:

generally been a successful model that's been resistant to attacks
involving the MAC.  The TLS model is "authenticate the entire packet".

Well, we do basically the same except that we need to leave out the
packet lengths because OpenPGP different here form TLS.  Find below my
changes on using non-chunked AEAD for secret keys and the SKESK.

I would just say a hard error is the right thing to do.  Clearly if
there's disagreement, we can't be sure what the sender intended.  It
would be better to fail than produce a bunch of junk data.

Well, it won't be junk data if the implementaion supports all required
algorithms.  For example the SKESK uses AES-256 to encrypt the session
key and the AEAD Encrypted Data Packet uses AES-128.  I can't see a
security problem here.


Salam-Shalom,

   Werner



--8<---------------cut here---------------start------------->8---
    Do not used chunked AEAD encryption for secret keys and SKESK.
    
    This also gives examples on how to encode the additional data.

        Modified   middle.mkd
diff --git a/middle.mkd b/middle.mkd
index a48a6fb..b7be5c6 100644
--- a/middle.mkd
+++ b/middle.mkd
@@ -1801,11 +1801,17 @@ ## {5.3} Symmetric-Key Encrypted Session Key Packets 
(Tag 3)
   * The encrypted session key itself, which is decrypted with the
     string-to-key object using the given cipher and AEAD mode.
 
-  * A final, summary authentication tag for the AEAD mode.
+  * An authentication tag for the AEAD mode.
+
+The encrypted session key is encrypted using one of the AEAD
+algorithms specified for the AEAD Encrypted Packet.  Note that no
+chunks are used and that there is only one authentication tag.  The
+Packet Tag in new format encoding (bits 7 and 6 set, bits 5-0 carry
+the packet tag), the packet version number, the cipher algorithm
+octet, and the AEAD algorithm octet are given as additional data.  For
+example, the additional data used with EAX and AES-128 consists of the
+octets 0xC3, 0x05, 0x07, and 0x01.
 
-The encrypted session key is encrypted exactly as an AEAD Encrypted Data
-packet with a chunk size octet of 10 would be.  This implicit chunk size
-octet is included in the normal calculations of additional data.
 
 ## {5.4} One-Pass Signature Packets (Tag 4)
 
@@ -1990,9 +1996,12 @@ ### {5.5.3} Secret-Key Packet Formats
     string-to-key specifier.  The length of the string-to-key
     specifier is implied by its type, as described above.
 
-  * [Optional] If secret data is encrypted (string-to-key usage
-    octet not zero), an Initial Vector (IV) of the same length as
-    the cipher's block size.
+  * [Optional] If secret data is encrypted (string-to-key usage octet
+    not zero), an Initial Vector (IV) of the same length as the
+    cipher's block size.  If string-to-key usage octet was 253 the IV
+    is used as the nonce for the AEAD algorithm.  If the AEAD
+    algorithm requires a shorter nonce, the high-order bits of the IV
+    are used and the remaining bits MUST be zero.
 
   * Only for a version 5 packet, a four-octet scalar octet count for
     the following key material.
@@ -2037,9 +2046,15 @@ ### {5.5.3} Secret-Key Packet Formats
 are encrypted, including the MPI bitcount prefix.
 
 If the string-to-key usage octet is 253, the encrypted MPI values are
-encrypted as one combined plaintext exactly as an AEAD Encrypted Data
-packet with a chunk size octet of 10 would be.  This implicit chunk size
-octet is included in the normal calculations of additional data.
+encrypted as one combined plaintext using one of the AEAD algorithms
+specified for the AEAD Encrypted Packet.  Note that no chunks are used
+and that there is only one authentication tag.  The Packet Tag in new
+format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag), the
+packet version number, the cipher algorithm octet, and the AEAD
+algorithm octet are given as additional data.  For example, the
+additional data used with EAX and AES-128 in a Secret-Key Packet of
+version 4 consists of the octets 0xC5, 0x04, 0x07, and 0x01; in a
+Secret-Subkey Packet the first octet would be 0xC7.
 
 The two-octet checksum that follows the algorithm-specific portion is
 the algebraic sum, mod 65536, of the plaintext of all the algorithm-
@@ -2050,7 +2065,9 @@ ### {5.5.3} Secret-Key Packet Formats
 deprecated; an implementation SHOULD NOT use it, but should rather use
 the SHA-1 hash denoted with a usage octet of 254.  The reason for this
 is that there are some attacks that involve undetectably modifying the
-secret key.
+secret key.  If the string-to-key usage octet is 253 no checksum or
+SHA-1 hash is used but the authentication tag of the AEAD algorithm
+follows.
 
 
 ## Algorithm-specific Parts of Keys
@@ -2640,7 +2657,10 @@ ## AEAD Encrypted Data Packet (Tag 20)
 format encoding (bits 7 and 6 set, bits 5-0 carry the packet tag),
 version number, cipher algorithm octet, AEAD algorithm octet, chunk
 size octet, and an eight-octet, big-endian chunk index as additional
-data.  The index of the first chunk is zero.
+data.  The index of the first chunk is zero.  For example, the
+additional data of the first chunk using EAX and AES-128 with a chunk
+size of 64 kiByte consists of the octets 0xD4, 0x01, 0x07, 0x01, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, and 0x00.
 
 After the final chunk, the AEAD algorithm is used to produce a final
 authentication tag encrypting the empty string.  This AEAD instance is
--8<---------------cut here---------------end--------------->8---



-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

Attachment: pgpb8D2ycY3Cj.pgp
Description: PGP signature

_______________________________________________
openpgp mailing list
openpgp(_at_)ietf(_dot_)org
https://www.ietf.org/mailman/listinfo/openpgp