• David Howells's avatar
    MODSIGN: Provide a script for generating a key ID from an X.509 cert · 85ecac79
    David Howells authored
    Provide a script to parse an X.509 certificate and certain pieces of
    information from it in order to generate a key identifier to be included within
    a module signature.
    
    The script takes the Subject Name and extracts (if present) the
    organizationName (O), the commonName (CN) and the emailAddress and fabricates
    the signer's name from them:
    
     (1) If both O and CN exist, then the name will be "O: CN", unless:
    
         (a) CN is prefixed by O, in which case only CN is used.
    
         (b) CN and O share at least the first 7 characters, in which case only CN
         	 is used.
    
     (2) Otherwise, CN is used if present.
    
     (3) Otherwise, O is used if present.
    
     (4) Otherwise the emailAddress is used, if present.
    
     (5) Otherwise a blank name is used.
    
    The script emits a binary encoded identifier in the following form:
    
     - 2 BE bytes indicating the length of the signer's name.
    
     - 2 BE bytes indicating the length of the subject key identifier.
    
     - The characters of the signer's name.
    
     - The bytes of the subject key identifier.
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
    85ecac79
x509keyid 7.98 KB