openssl / openssl

TLS/SSL and crypto library
https://www.openssl.org
Apache License 2.0
24.91k stars 9.93k forks source link

openssl cms -cmsout -print renders 15 octets per row (should be 16) #14895

Open dkg opened 3 years ago

dkg commented 3 years ago

Using OpenSSL 1.1.1k-1 (in debian), i see block output split in rows of 15 octets. This is surprising -- most hex output renders in rows of 16 octets:

$ openssl cms -cmsout -print -noout -inform SMIME < smime-enc-signed.eml
CMS_ContentInfo: 
  contentType: pkcs7-envelopedData (1.2.840.113549.1.7.3)
  d.envelopedData: 
    version: 0
    originatorInfo: <ABSENT>
    recipientInfos:
      d.ktri: 
        version: 0
        d.issuerAndSerialNumber: 
          issuer: CN=Sample LAMPS Certificate Authority
          serialNumber: 0x3B5EC15A471D85FC261CDEEE7AE3F38AE516D4
        keyEncryptionAlgorithm: 
          algorithm: rsaEncryption (1.2.840.113549.1.1.1)
          parameter: NULL
        encryptedKey: 
          0000 - 57 d6 71 3d 4f a0 a9 79-8e f3 4c 10 54 86 e0   W.q=O..y..L.T..
          000f - 33 5d b7 88 63 4f 5f 85-d2 49 4c a7 c0 dc 36   3]..cO_..IL...6
          001e - b3 43 cd cd 5f cf d1 a3-72 7a 4d ef 58 6a 97   .C.._...rzM.Xj.
          002d - e2 b0 0d ae a9 45 41 42-fe b2 00 16 a6 35 4d   .....EAB.....5M
          003c - ee 4f 0c d0 99 e9 33 96-51 cd 4b 46 f2 52 1c   .O....3.Q.KF.R.
          004b - 73 c5 5a cd d4 bf 17 c0-a9 5f 9d bb 7e a2 de   s.Z......_..~..
          005a - cf 64 c8 7e 18 da eb 46-ac 8e 3b b7 ce b8 ca   .d.~...F..;....
          0069 - db 1c 17 ca 70 8f 53 a6-69 ab d8 6c e3 51 db   ....p.S.i..l.Q.
          0078 - 00 43 21 0b 04 98 7e 5d-f1 7e 00 77 73 f0 e9   .C!...~].~.ws..
          0087 - f8 a1 4b 46 d6 5e c8 d6-6f 1b 15 be 3d 5d 99   ..KF.^..o...=].
          0096 - fc b7 eb b5 72 a2 23 93-22 41 7a a7 8d 20 57   ....r.#."Az.. W
          00a5 - 40 a6 13 dd f0 ce 23 bc-75 b0 b4 63 34 30 9e   @.....#.u..c40.
          00b4 - f0 53 35 22 bb af 17 ab-6f 5c 28 b4 41 8a 6c   .S5"....o\(.A.l
          00c3 - 5a d8 a5 91 d6 8b a4 21-92 54 d4 4a 45 3b da   Z......!.T.JE;.
          00d2 - 9e 83 52 cd 0c 6e 07 fa-f3 e3 0a 67 f0 00 b1   ..R..n.....g...
          00e1 - 2e 81 66 83 17 7f f6 cf-11 13 65 97 8d bb ca   ..f.......e....
          00f0 - a5 1d fb 2a 8a 18 bd 3b-bd 20 cd 33 88 24 9b   ...*...;. .3.$.
          00ff - 08                                             .
[…]

Block output should be rendered in rows of 16, not 15, for the sake of standard reading.

paulidale commented 3 years ago

It's wrapping at 79 characters per line. Adding the extra octet would make it 83. Is there a standard that mandates 16 octets per line or is this a case of unlucky indentation?

dkg commented 3 years ago

I don't know whether there is a standard, but I've never seen a hexdump that doesn't wrap at 16 octets, particularly when there's an ASCII-rendering right-hand column.

There's even a hyphen after the first 8 octets, too, which i'd normally expect to see as a delimiter for the halfway point of the line (hd uses two spaces to delimit the halfway mark), but of course only 7 octets follow the hyphen.