1. 03 10月, 2014 1 次提交
  2. 17 9月, 2014 1 次提交
    • D
      KEYS: Overhaul key identification when searching for asymmetric keys · 46963b77
      David Howells 提交于
      Make use of the new match string preparsing to overhaul key identification
      when searching for asymmetric keys.  The following changes are made:
      
       (1) Use the previously created asymmetric_key_id struct to hold the following
           key IDs derived from the X.509 certificate or PKCS#7 message:
      
      	id: serial number + issuer
      	skid: subjKeyId + subject
      	authority: authKeyId + issuer
      
       (2) Replace the hex fingerprint attached to key->type_data[1] with an
           asymmetric_key_ids struct containing the id and the skid (if present).
      
       (3) Make the asymmetric_type match data preparse select one of two searches:
      
           (a) An iterative search for the key ID given if prefixed with "id:".  The
           	 prefix is expected to be followed by a hex string giving the ID to
           	 search for.  The criterion key ID is checked against all key IDs
           	 recorded on the key.
      
           (b) A direct search if the key ID is not prefixed with "id:".  This will
           	 look for an exact match on the key description.
      
       (4) Make x509_request_asymmetric_key() take a key ID.  This is then converted
           into "id:<hex>" and passed into keyring_search() where match preparsing
           will turn it back into a binary ID.
      
       (5) X.509 certificate verification then takes the authority key ID and looks
           up a key that matches it to find the public key for the certificate
           signature.
      
       (6) PKCS#7 certificate verification then takes the id key ID and looks up a
           key that matches it to find the public key for the signed information
           block signature.
      
      Additional changes:
      
       (1) Multiple subjKeyId and authKeyId values on an X.509 certificate cause the
           cert to be rejected with -EBADMSG.
      
       (2) The 'fingerprint' ID is gone.  This was primarily intended to convey PGP
           public key fingerprints.  If PGP is supported in future, this should
           generate a key ID that carries the fingerprint.
      
       (3) Th ca_keyid= kernel command line option is now converted to a key ID and
           used to match the authority key ID.  Possibly this should only match the
           actual authKeyId part and not the issuer as well.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      46963b77
  3. 03 7月, 2014 1 次提交
  4. 01 7月, 2014 1 次提交
  5. 26 10月, 2013 1 次提交
  6. 26 9月, 2013 2 次提交
  7. 22 4月, 2013 1 次提交
    • C
      X.509: Support parse long form of length octets in Authority Key Identifier · 04b00bdb
      Chun-Yi Lee 提交于
      Per X.509 spec in 4.2.1.1 section, the structure of Authority Key
      Identifier Extension is:
      
         AuthorityKeyIdentifier ::= SEQUENCE {
            keyIdentifier             [0] KeyIdentifier           OPTIONAL,
            authorityCertIssuer       [1] GeneralNames            OPTIONAL,
            authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL  }
      
         KeyIdentifier ::= OCTET STRING
      
      When a certificate also provides
      authorityCertIssuer and authorityCertSerialNumber then the length of
      AuthorityKeyIdentifier SEQUENCE is likely to long form format.
      e.g.
         The example certificate demos/tunala/A-server.pem in openssl source:
      
      X509v3 Authority Key Identifier:
          keyid:49:FB:45:72:12:C4:CC:E1:45:A1:D3:08:9E:95:C4:2C:6D:55:3F:17
          DirName:/C=NZ/L=Wellington/O=Really Irresponsible Authorisation Authority (RIAA)/OU=Cert-stamping/CN=Jackov al-Trades/emailAddress=none@fake.domain
          serial:00
      
      Current parsing rule of OID_authorityKeyIdentifier only take care the
      short form format, it causes load certificate to modsign_keyring fail:
      
      [   12.061147] X.509: Extension: 47
      [   12.075121] MODSIGN: Problem loading in-kernel X.509 certificate (-74)
      
      So, this patch add the parsing rule for support long form format against
      Authority Key Identifier.
      
      v3:
      Changed the size check in "Short Form length" case, we allow v[3] smaller
      then (vlen - 4) because authorityCertIssuer and authorityCertSerialNumber
      are also possible attach in AuthorityKeyIdentifier sequence.
      
      v2:
       - Removed comma from author's name.
       - Moved 'Short Form length' comment inside the if-body.
       - Changed the type of sub to size_t.
       - Use ASN1_INDEFINITE_LENGTH rather than writing 0x80 and 127.
       - Moved the key_len's value assignment before alter v.
       - Fixed the typo of octets.
       - Add 2 to v before entering the loop for calculate the length.
       - Removed the comment of check vlen.
      
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Josh Boyer <jwboyer@redhat.com>
      Cc: Randy Dunlap <rdunlap@xenotime.net>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: "David S. Miller" <davem@davemloft.net>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NChun-Yi Lee <jlee@suse.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      04b00bdb
  8. 10 10月, 2012 2 次提交
  9. 08 10月, 2012 1 次提交
    • D
      X.509: Add a crypto key parser for binary (DER) X.509 certificates · c26fd69f
      David Howells 提交于
      Add a crypto key parser for binary (DER) encoded X.509 certificates.  The
      certificate is parsed and, if possible, the signature is verified.
      
      An X.509 key can be added like this:
      
      	# keyctl padd crypto bar @s </tmp/x509.cert
      	15768135
      
      and displayed like this:
      
      	# cat /proc/keys
      	00f09a47 I--Q---     1 perm 39390000     0     0 asymmetri bar: X509.RSA e9fd6d08 []
      
      Note that this only works with binary certificates.  PEM encoded certificates
      are ignored by the parser.
      
      Note also that the X.509 key ID is not congruent with the PGP key ID, but for
      the moment, they will match.
      
      If a NULL or "" name is given to add_key(), then the parser will generate a key
      description from the CertificateSerialNumber and Name fields of the
      TBSCertificate:
      
      	00aefc4e I--Q---     1 perm 39390000     0     0 asymmetri bfbc0cd76d050ea4:/C=GB/L=Cambridge/O=Red Hat/CN=kernel key: X509.RSA 0c688c7b []
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      c26fd69f