1. 06 4月, 2016 5 次提交
  2. 23 3月, 2016 1 次提交
    • N
      PKCS#7: pkcs7_validate_trust(): initialize the _trusted output argument · e5435891
      Nicolai Stange 提交于
      Despite what the DocBook comment to pkcs7_validate_trust() says, the
      *_trusted argument is never set to false.
      
      pkcs7_validate_trust() only positively sets *_trusted upon encountering
      a trusted PKCS#7 SignedInfo block.
      
      This is quite unfortunate since its callers, system_verify_data() for
      example, depend on pkcs7_validate_trust() clearing *_trusted on non-trust.
      
      Indeed, UBSAN splats when attempting to load the uninitialized local
      variable 'trusted' from system_verify_data() in pkcs7_validate_trust():
      
        UBSAN: Undefined behaviour in crypto/asymmetric_keys/pkcs7_trust.c:194:14
        load of value 82 is not a valid value for type '_Bool'
        [...]
        Call Trace:
          [<ffffffff818c4d35>] dump_stack+0xbc/0x117
          [<ffffffff818c4c79>] ? _atomic_dec_and_lock+0x169/0x169
          [<ffffffff8194113b>] ubsan_epilogue+0xd/0x4e
          [<ffffffff819419fa>] __ubsan_handle_load_invalid_value+0x111/0x158
          [<ffffffff819418e9>] ? val_to_string.constprop.12+0xcf/0xcf
          [<ffffffff818334a4>] ? x509_request_asymmetric_key+0x114/0x370
          [<ffffffff814b83f0>] ? kfree+0x220/0x370
          [<ffffffff818312c2>] ? public_key_verify_signature_2+0x32/0x50
          [<ffffffff81835e04>] pkcs7_validate_trust+0x524/0x5f0
          [<ffffffff813c391a>] system_verify_data+0xca/0x170
          [<ffffffff813c3850>] ? top_trace_array+0x9b/0x9b
          [<ffffffff81510b29>] ? __vfs_read+0x279/0x3d0
          [<ffffffff8129372f>] mod_verify_sig+0x1ff/0x290
          [...]
      
      The implication is that pkcs7_validate_trust() effectively grants trust
      when it really shouldn't have.
      
      Fix this by explicitly setting *_trusted to false at the very beginning
      of pkcs7_validate_trust().
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicolai Stange <nicstange@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      e5435891
  3. 04 3月, 2016 2 次提交
    • D
      X.509: Make algo identifiers text instead of enum · 4e8ae72a
      David Howells 提交于
      Make the identifier public key and digest algorithm fields text instead of
      enum.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      4e8ae72a
    • D
      akcipher: Move the RSA DER encoding check to the crypto layer · d43de6c7
      David Howells 提交于
      Move the RSA EMSA-PKCS1-v1_5 encoding from the asymmetric-key public_key
      subtype to the rsa crypto module's pkcs1pad template.  This means that the
      public_key subtype no longer has any dependencies on public key type.
      
      To make this work, the following changes have been made:
      
       (1) The rsa pkcs1pad template is now used for RSA keys.  This strips off the
           padding and returns just the message hash.
      
       (2) In a previous patch, the pkcs1pad template gained an optional second
           parameter that, if given, specifies the hash used.  We now give this,
           and pkcs1pad checks the encoded message E(M) for the EMSA-PKCS1-v1_5
           encoding and verifies that the correct digest OID is present.
      
       (3) The crypto driver in crypto/asymmetric_keys/rsa.c is now reduced to
           something that doesn't care about what the encryption actually does
           and and has been merged into public_key.c.
      
       (4) CONFIG_PUBLIC_KEY_ALGO_RSA is gone.  Module signing must set
           CONFIG_CRYPTO_RSA=y instead.
      
      Thoughts:
      
       (*) Should the encoding style (eg. raw, EMSA-PKCS1-v1_5) also be passed to
           the padding template?  Should there be multiple padding templates
           registered that share most of the code?
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NTadeusz Struk <tadeusz.struk@intel.com>
      Acked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      d43de6c7
  4. 29 2月, 2016 4 次提交
    • D
      X.509: Handle midnight alternative notation in GeneralizedTime · 7650cb80
      David Howells 提交于
      The ASN.1 GeneralizedTime object carries an ISO 8601 format date and time.
      The time is permitted to show midnight as 00:00 or 24:00 (the latter being
      equivalent of 00:00 of the following day).
      
      The permitted value is checked in x509_decode_time() but the actual
      handling is left to mktime64().
      
      Without this patch, certain X.509 certificates will be rejected and could
      lead to an unbootable kernel.
      
      Note that with this patch we also permit any 24:mm:ss time and extend this
      to UTCTime, which whilst not strictly correct don't permit much leeway in
      fiddling date strings.
      Reported-by: NRudolf Polzer <rpolzer@google.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      cc: David Woodhouse <David.Woodhouse@intel.com>
      cc: John Stultz <john.stultz@linaro.org>
      7650cb80
    • D
      X.509: Support leap seconds · da02559c
      David Howells 提交于
      The format of ASN.1 GeneralizedTime seems to be specified by ISO 8601
      [X.680 46.3] and this apparently supports leap seconds (ie. the seconds
      field is 60).  It's not entirely clear that ASN.1 expects it, but we can
      relax the seconds check slightly for GeneralizedTime.
      
      This results in us passing a time with sec as 60 to mktime64(), which
      handles it as being a duplicate of the 0th second of the next minute.
      
      We can't really do otherwise without giving the kernel much greater
      knowledge of where all the leap seconds are.  Unfortunately, this would
      require change the mapping of the kernel's current-time-in-seconds.
      
      UTCTime, however, only supports a seconds value in the range 00-59, but for
      the sake of simplicity allow this with UTCTime also.
      
      Without this patch, certain X.509 certificates will be rejected,
      potentially making a kernel unbootable.
      Reported-by: NRudolf Polzer <rpolzer@google.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      cc: David Woodhouse <David.Woodhouse@intel.com>
      cc: John Stultz <john.stultz@linaro.org>
      da02559c
    • D
      X.509: Fix leap year handling again · ac4cbedf
      David Howells 提交于
      There are still a couple of minor issues in the X.509 leap year handling:
      
       (1) To avoid doing a modulus-by-400 in addition to a modulus-by-100 when
           determining whether the year is a leap year or not, I divided the year
           by 100 after doing the modulus-by-100, thereby letting the compiler do
           one instruction for both, and then did a modulus-by-4.
      
           Unfortunately, I then passed the now-modified year value to mktime64()
           to construct a time value.
      
           Since this isn't a fast path and since mktime64() does a bunch of
           divisions, just condense down to "% 400".  It's also easier to read.
      
       (2) The default month length for any February where the year doesn't
           divide by four exactly is obtained from the month_length[] array where
           the value is 29, not 28.
      
           This is fixed by altering the table.
      Reported-by: NRudolf Polzer <rpolzer@google.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      cc: stable@vger.kernel.org
      ac4cbedf
    • C
      PKCS#7: fix unitialized boolean 'want' · 06aae592
      Colin Ian King 提交于
      The boolean want is not initialized and hence garbage. The default should
      be false (later it is only set to true on tne sinfo->authattrs check).
      
      Found with static analysis using CoverityScan
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      06aae592
  5. 10 2月, 2016 1 次提交
  6. 09 2月, 2016 1 次提交
  7. 06 2月, 2016 1 次提交
  8. 25 1月, 2016 1 次提交
    • P
      PKCS#7: Don't require SpcSpOpusInfo in Authenticode pkcs7 signatures · 7ee7014d
      Peter Jones 提交于
      Dave Young reported:
      > Hi,
      >
      > I saw the warning "Missing required AuthAttr" when testing kexec,
      > known issue?  Idea about how to fix it?
      >
      > The kernel is latest linus tree plus sevral patches from Toshi to
      > cleanup io resource structure.
      >
      > in function pkcs7_sig_note_set_of_authattrs():
      >         if (!test_bit(sinfo_has_content_type, &sinfo->aa_set) ||
      >             !test_bit(sinfo_has_message_digest, &sinfo->aa_set) ||
      >             (ctx->msg->data_type == OID_msIndirectData &&
      >              !test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))) {
      >                 pr_warn("Missing required AuthAttr\n");
      >                 return -EBADMSG;
      >         }
      >
      > The third condition below is true:
      > (ctx->msg->data_type == OID_msIndirectData &&
      >              !test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))
      >
      > I signed the kernel with redhat test key like below:
      > pesign -c 'Red Hat Test Certificate' -i arch/x86/boot/bzImage -o /boot/vmlinuz-4.4.0-rc8+ -s --force
      
      And right he is!  The Authenticode specification is a paragon amongst
      technical documents, and has this pearl of wisdom to offer:
      
      ---------------------------------
      Authenticode-Specific SignerInfo UnauthenticatedAttributes Structures
      
        The following Authenticode-specific data structures are present in
        SignerInfo authenticated attributes.
      
        SpcSpOpusInfo
        SpcSpOpusInfo is identified by SPC_SP_OPUS_INFO_OBJID
        (1.3.6.1.4.1.311.2.1.12) and is defined as follows:
        SpcSpOpusInfo ::= SEQUENCE {
          programName  [0] EXPLICIT SpcString OPTIONAL,
          moreInfo     [1] EXPLICIT SpcLink OPTIONAL,
        } --#public--
      
        SpcSpOpusInfo has two fields:
          programName
            This field contains the program description:
            If publisher chooses not to specify a description, the SpcString
            structure contains a zero-length program name.
            If the publisher chooses to specify a
            description, the SpcString structure contains a Unicode string.
          moreInfo
            This field is set to an SPCLink structure that contains a URL for
            a Web site with more information about the signer. The URL is an
            ASCII string.
      ---------------------------------
      
      Which is to say that this is an optional *unauthenticated* field which
      may be present in the Authenticated Attribute list.  This is not how
      pkcs7 is supposed to work, so when David implemented this, he didn't
      appreciate the subtlety the original spec author was working with, and
      missed the part of the sublime prose that says this Authenticated
      Attribute is an Unauthenticated Attribute.  As a result, the code in
      question simply takes as given that the Authenticated Attributes should
      be authenticated.
      
      But this one should not, individually.  Because it says it's not
      authenticated.
      
      It still has to hash right so the TBS digest is correct.  So it is both
      authenticated and unauthenticated, all at once.  Truly, a wonder of
      technical accomplishment.
      
      Additionally, pesign's implementation has always attempted to be
      compatible with the signatures emitted from contemporary versions of
      Microsoft's signtool.exe.  During the initial implementation, Microsoft
      signatures always produced the same values for SpcSpOpusInfo -
      {U"Microsoft Windows", "http://www.microsoft.com"} - without regard to
      who the signer was.
      
      Sometime between Windows 8 and Windows 8.1 they stopped including the
      field in their signatures altogether, and as such pesign stopped
      producing them in commits c0c4da6 and d79cb0c, sometime around June of
      2012.  The theory here is that anything that breaks with
      pesign signatures would also be breaking with signtool.exe sigs as well,
      and that'll be a more noticed problem for firmwares parsing it, so it'll
      get fixed.  The fact that we've done exactly this bug in Linux code is
      first class, grade A irony.
      
      So anyway, we should not be checking this field for presence or any
      particular value: if the field exists, it should be at the right place,
      but aside from that, as long as the hash matches the field is good.
      Signed-off-by: NPeter Jones <pjones@redhat.com>
      Tested-by: NDave Young <dyoung@redhat.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      7ee7014d
  9. 15 12月, 2015 1 次提交
    • P
      IMA: create machine owner and blacklist keyrings · 41c89b64
      Petko Manolov 提交于
      This option creates IMA MOK and blacklist keyrings.  IMA MOK is an
      intermediate keyring that sits between .system and .ima keyrings,
      effectively forming a simple CA hierarchy.  To successfully import a key
      into .ima_mok it must be signed by a key which CA is in .system keyring.
      On turn any key that needs to go in .ima keyring must be signed by CA in
      either .system or .ima_mok keyrings. IMA MOK is empty at kernel boot.
      
      IMA blacklist keyring contains all revoked IMA keys.  It is consulted
      before any other keyring.  If the search is successful the requested
      operation is rejected and error is returned to the caller.
      Signed-off-by: NPetko Manolov <petkan@mip-labs.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      41c89b64
  10. 11 12月, 2015 1 次提交
  11. 12 11月, 2015 1 次提交
    • D
      X.509: Fix the time validation [ver #2] · cc25b994
      David Howells 提交于
      This fixes CVE-2015-5327.  It affects kernels from 4.3-rc1 onwards.
      
      Fix the X.509 time validation to use month number-1 when looking up the
      number of days in that month.  Also put the month number validation before
      doing the lookup so as not to risk overrunning the array.
      
      This can be tested by doing the following:
      
      cat <<EOF | openssl x509 -outform DER | keyctl padd asymmetric "" @s
      -----BEGIN CERTIFICATE-----
      MIIDbjCCAlagAwIBAgIJAN/lUld+VR4hMA0GCSqGSIb3DQEBCwUAMCkxETAPBgNV
      BAoMCGxvY2FsLWNhMRQwEgYDVQQDDAtzaWduaW5nIGtleTAeFw0xNTA5MDEyMTMw
      MThaFw0xNjA4MzEyMTMwMThaMCkxETAPBgNVBAoMCGxvY2FsLWNhMRQwEgYDVQQD
      DAtzaWduaW5nIGtleTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANrn
      crcMfMeG67nagX4+m02Xk9rkmsMKI5XTUxbikROe7GSUVJ27sPVPZp4mgzoWlvhh
      jfK8CC/qhEhwep8Pgg4EJZyWOjhZb7R97ckGvLIoUC6IO3FC2ZnR7WtmWDgo2Jcj
      VlXwJdHhKU1VZwulh81O61N8IBKqz2r/kDhIWiicUCUkI/Do/RMRfKAoDBcSh86m
      gOeIAGfq62vbiZhVsX5dOE8Oo2TK5weAvwUIOR7OuGBl5AqwFlPnXQolewiHzKry
      THg9e44HfzG4Mi6wUvcJxVaQT1h5SrKD779Z5+8+wf1JLaooetcEUArvWyuxCU59
      qxA4lsTjBwl4cmEki+cCAwEAAaOBmDCBlTAMBgNVHRMEBTADAQH/MAsGA1UdDwQE
      AwIHgDAdBgNVHQ4EFgQUyND/eKUis7ep/hXMJ8iZMdUhI+IwWQYDVR0jBFIwUIAU
      yND/eKUis7ep/hXMJ8iZMdUhI+KhLaQrMCkxETAPBgNVBAoMCGxvY2FsLWNhMRQw
      EgYDVQQDDAtzaWduaW5nIGtleYIJAN/lUld+VR4hMA0GCSqGSIb3DQEBCwUAA4IB
      AQAMqm1N1yD5pimUELLhT5eO2lRdGUfTozljRxc7e2QT3RLk2TtGhg65JFFN6eml
      XS58AEPVcAsSLDlR6WpOpOLB2giM0+fV/eYFHHmh22yqTJl4YgkdUwyzPdCHNOZL
      hmSKeY9xliHb6PNrNWWtZwhYYvRaO2DX4GXOMR0Oa2O4vaYu6/qGlZOZv3U6qZLY
      wwHEJSrqeBDyMuwN+eANHpoSpiBzD77S4e+7hUDJnql4j6xzJ65+nWJ89fCrQypR
      4sN5R3aGeIh3QAQUIKpHilwek0CtEaYERgc5m+jGyKSc1rezJW62hWRTaitOc+d5
      G5hh+9YpnYcxQHEKnZ7rFNKJ
      -----END CERTIFICATE-----
      EOF
      
      If it works, it emit a key ID; if it fails, it should give a bad message
      error.
      Reported-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Acked-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      cc25b994
  12. 21 10月, 2015 1 次提交
    • D
      KEYS: Merge the type-specific data with the payload data · 146aa8b1
      David Howells 提交于
      Merge the type-specific data with the payload data into one four-word chunk
      as it seems pointless to keep them separate.
      
      Use user_key_payload() for accessing the payloads of overloaded
      user-defined keys.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: linux-cifs@vger.kernel.org
      cc: ecryptfs@vger.kernel.org
      cc: linux-ext4@vger.kernel.org
      cc: linux-f2fs-devel@lists.sourceforge.net
      cc: linux-nfs@vger.kernel.org
      cc: ceph-devel@vger.kernel.org
      cc: linux-ima-devel@lists.sourceforge.net
      146aa8b1
  13. 20 10月, 2015 1 次提交
  14. 14 10月, 2015 1 次提交
    • S
      crypto: pkcs7 - Fix unaligned access in pkcs7_verify() · 62f57d05
      Sowmini Varadhan 提交于
      On sparc, we see unaligned access messages on each modprobe[-r]:
      
      Kernel unaligned access at TPC[6ad9b4] pkcs7_verify [..]
      Kernel unaligned access at TPC[6a5484] crypto_shash_finup [..]
      Kernel unaligned access at TPC[6a5390] crypto_shash_update [..]
      Kernel unaligned access at TPC[10150308] sha1_sparc64_update [..]
      Kernel unaligned access at TPC[101501ac] __sha1_sparc64_update [..]
      
      These ware triggered by mod_verify_sig() invocations of pkcs_verify(), and
      are are being caused by an unaligned desc at (sha1, digest_size is 0x14)
              desc = digest + digest_size;
      
      To fix this, pkcs7_verify needs to make sure that desc is pointing
      at an aligned value past the digest_size, and kzalloc appropriately,
      taking alignment values into consideration.
      Signed-off-by: NSowmini Varadhan <sowmini.varadhan@oracle.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      62f57d05
  15. 25 9月, 2015 1 次提交
    • D
      X.509: Don't strip leading 00's from key ID when constructing key description · e7c87bef
      David Howells 提交于
      Don't strip leading zeros from the crypto key ID when using it to construct
      the struct key description as the signature in kernels up to and including
      4.2 matched this aspect of the key.  This means that 1 in 256 keys won't
      actually match if their key ID begins with 00.
      
      The key ID is stored in the module signature as binary and so must be
      converted to text in order to invoke request_key() - but it isn't stripped
      at this point.
      
      Something like this is likely to be observed in dmesg when the key is loaded:
      
      [    1.572423] Loaded X.509 cert 'Build time autogenerated kernel
          key: 62a7c3d2da278be024da4af8652c071f3fea33'
      
      followed by this when we try and use it:
      
        [    1.646153] Request for unknown module key 'Build time autogenerated
          kernel key: 0062a7c3d2da278be024da4af8652c071f3fea33' err -11
      
      The 'Loaded' line should show an extra '00' on the front of the hex string.
      
      This problem should not affect 4.3-rc1 and onwards because there the key
      should be matched on one of its auxiliary identities rather than the key
      struct's description string.
      Reported-by: NArjan van de Ven <arjan@linux.intel.com>
      Reported-by: NAndy Whitcroft <apw@canonical.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      e7c87bef
  16. 21 9月, 2015 1 次提交
  17. 01 9月, 2015 1 次提交
  18. 13 8月, 2015 7 次提交
    • D
      PKCS#7: Add MODULE_LICENSE() to test module · 772111ab
      David Howells 提交于
      Add a MODULE_LICENSE() line to the PKCS#7 test key module to fix this
      warning:
      
      	WARNING: modpost: missing MODULE_LICENSE() in
      	crypto/asymmetric_keys/pkcs7_test_key.o
      
      Whilst we're at it, also add a module description.
      Reported-by: NJames Morris <jmorris@namei.org>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      772111ab
    • D
      PKCS#7: Appropriately restrict authenticated attributes and content type · 99db4435
      David Howells 提交于
      A PKCS#7 or CMS message can have per-signature authenticated attributes
      that are digested as a lump and signed by the authorising key for that
      signature.  If such attributes exist, the content digest isn't itself
      signed, but rather it is included in a special authattr which then
      contributes to the signature.
      
      Further, we already require the master message content type to be
      pkcs7_signedData - but there's also a separate content type for the data
      itself within the SignedData object and this must be repeated inside the
      authattrs for each signer [RFC2315 9.2, RFC5652 11.1].
      
      We should really validate the authattrs if they exist or forbid them
      entirely as appropriate.  To this end:
      
       (1) Alter the PKCS#7 parser to reject any message that has more than one
           signature where at least one signature has authattrs and at least one
           that does not.
      
       (2) Validate authattrs if they are present and strongly restrict them.
           Only the following authattrs are permitted and all others are
           rejected:
      
           (a) contentType.  This is checked to be an OID that matches the
           	 content type in the SignedData object.
      
           (b) messageDigest.  This must match the crypto digest of the data.
      
           (c) signingTime.  If present, we check that this is a valid, parseable
           	 UTCTime or GeneralTime and that the date it encodes fits within
           	 the validity window of the matching X.509 cert.
      
           (d) S/MIME capabilities.  We don't check the contents.
      
           (e) Authenticode SP Opus Info.  We don't check the contents.
      
           (f) Authenticode Statement Type.  We don't check the contents.
      
           The message is rejected if (a) or (b) are missing.  If the message is
           an Authenticode type, the message is rejected if (e) is missing; if
           not Authenticode, the message is rejected if (d) - (f) are present.
      
           The S/MIME capabilities authattr (d) unfortunately has to be allowed
           to support kernels already signed by the pesign program.  This only
           affects kexec.  sign-file suppresses them (CMS_NOSMIMECAP).
      
           The message is also rejected if an authattr is given more than once or
           if it contains more than one element in its set of values.
      
       (3) Add a parameter to pkcs7_verify() to select one of the following
           restrictions and pass in the appropriate option from the callers:
      
           (*) VERIFYING_MODULE_SIGNATURE
      
      	 This requires that the SignedData content type be pkcs7-data and
      	 forbids authattrs.  sign-file sets CMS_NOATTR.  We could be more
      	 flexible and permit authattrs optionally, but only permit minimal
      	 content.
      
           (*) VERIFYING_FIRMWARE_SIGNATURE
      
      	 This requires that the SignedData content type be pkcs7-data and
      	 requires authattrs.  In future, this will require an attribute
      	 holding the target firmware name in addition to the minimal set.
      
           (*) VERIFYING_UNSPECIFIED_SIGNATURE
      
      	 This requires that the SignedData content type be pkcs7-data but
      	 allows either no authattrs or only permits the minimal set.
      
           (*) VERIFYING_KEXEC_PE_SIGNATURE
      
      	 This only supports the Authenticode SPC_INDIRECT_DATA content type
      	 and requires at least an SpcSpOpusInfo authattr in addition to the
      	 minimal set.  It also permits an SPC_STATEMENT_TYPE authattr (and
      	 an S/MIME capabilities authattr because the pesign program doesn't
      	 remove these).
      
           (*) VERIFYING_KEY_SIGNATURE
           (*) VERIFYING_KEY_SELF_SIGNATURE
      
      	 These are invalid in this context but are included for later use
      	 when limiting the use of X.509 certs.
      
       (4) The pkcs7_test key type is given a module parameter to select between
           the above options for testing purposes.  For example:
      
      	echo 1 >/sys/module/pkcs7_test_key/parameters/usage
      	keyctl padd pkcs7_test foo @s </tmp/stuff.pkcs7
      
           will attempt to check the signature on stuff.pkcs7 as if it contains a
           firmware blob (1 being VERIFYING_FIRMWARE_SIGNATURE).
      Suggested-by: NAndy Lutomirski <luto@kernel.org>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-by: NMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      99db4435
    • D
      KEYS: Add a name for PKEY_ID_PKCS7 · f29299b4
      David Howells 提交于
      Add a name for PKEY_ID_PKCS7 into the pkey_id_type_name array.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      f29299b4
    • D
      PKCS#7: Improve and export the X.509 ASN.1 time object decoder · fd19a3d1
      David Howells 提交于
      Make the X.509 ASN.1 time object decoder fill in a time64_t rather than a
      struct tm to make comparison easier (unfortunately, this makes readable
      display less easy) and export it so that it can be used by the PKCS#7 code
      too.
      
      Further, tighten up its parsing to reject invalid dates (eg. weird
      characters, non-existent hour numbers) and unsupported dates (eg. timezones
      other than 'Z' or dates earlier than 1970).
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-by: NDavid Woodhouse <David.Woodhouse@intel.com>
      fd19a3d1
    • D
      PKCS#7: Support CMS messages also [RFC5652] · 60d65cac
      David Howells 提交于
      Since CMS is an evolution of PKCS#7, with much of the ASN.1 being
      compatible, add support for CMS signed-data messages also [RFC5652 sec 5].
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-By: NDavid Woodhouse <David.Woodhouse@intel.com>
      60d65cac
    • D
      X.509: Change recorded SKID & AKID to not include Subject or Issuer · a4c6e57f
      David Howells 提交于
      The key identifiers fabricated from an X.509 certificate are currently:
      
       (A) Concatenation of serial number and issuer
      
       (B) Concatenation of subject and subjectKeyID (SKID)
      
      When verifying one X.509 certificate with another, the AKID in the target
      can be used to match the authoritative certificate.  The AKID can specify
      the match in one or both of two ways:
      
       (1) Compare authorityCertSerialNumber and authorityCertIssuer from the AKID
           to identifier (A) above.
      
       (2) Compare keyIdentifier from the AKID plus the issuer from the target
           certificate to identifier (B) above.
      
      When verifying a PKCS#7 message, the only available comparison is between
      the IssuerAndSerialNumber field and identifier (A) above.
      
      However, a subsequent patch adds CMS support.  Whilst CMS still supports a
      match on IssuerAndSerialNumber as for PKCS#7, it also supports an
      alternative - which is the SubjectKeyIdentifier field.  This is used to
      match to an X.509 certificate on the SKID alone.  No subject information is
      available to be used.
      
      To this end change the fabrication of (B) above to be from the X.509 SKID
      alone.  The AKID in keyIdentifier form then only matches on that and does
      not include the issuer.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-By: NDavid Woodhouse <David.Woodhouse@intel.com>
      a4c6e57f
    • D
      PKCS#7: Check content type and versions · 2c7fd367
      David Howells 提交于
      We only support PKCS#7 signed-data [RFC2315 sec 9] content at the top level,
      so reject anything else.  Further, check that the version numbers in
      SignedData and SignerInfo are 1 in both cases.
      
      Note that we don't restrict the inner content type.  In the PKCS#7 code we
      don't parse the data attached there, but merely verify the signature over
      it.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-By: NDavid Woodhouse <David.Woodhouse@intel.com>
      2c7fd367
  19. 07 8月, 2015 3 次提交
  20. 25 6月, 2015 1 次提交
    • G
      crypto: asymmetric_keys/rsa - Use non-conflicting variable name · 2cdcc357
      Guenter Roeck 提交于
      arm64:allmodconfig fails to build as follows.
      
      In file included from include/acpi/platform/aclinux.h:74:0,
                       from include/acpi/platform/acenv.h:173,
                       from include/acpi/acpi.h:56,
                       from include/linux/acpi.h:37,
                       from ./arch/arm64/include/asm/dma-mapping.h:21,
                       from include/linux/dma-mapping.h:86,
                       from include/linux/skbuff.h:34,
                       from include/crypto/algapi.h:18,
                       from crypto/asymmetric_keys/rsa.c:16:
      include/linux/ctype.h:15:12: error: expected ‘;’, ‘,’ or ‘)’
      		before numeric constant
       #define _X 0x40 /* hex digit */
                  ^
      crypto/asymmetric_keys/rsa.c:123:47: note: in expansion of macro ‘_X’
       static int RSA_I2OSP(MPI x, size_t xLen, u8 **_X)
                                                     ^
      crypto/asymmetric_keys/rsa.c: In function ‘RSA_verify_signature’:
      crypto/asymmetric_keys/rsa.c:256:2: error:
      		implicit declaration of function ‘RSA_I2OSP’
      
      The problem is caused by an unrelated include file change, resulting in
      the inclusion of ctype.h on arm64. This in turn causes the local variable
      _X to conflict with macro _X used in ctype.h.
      
      Fixes: b6197b93 ("arm64 : Introduce support for ACPI _CCA object")
      Cc: Suthikulpanit, Suravee <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      2cdcc357
  21. 17 6月, 2015 1 次提交
  22. 22 5月, 2015 1 次提交
    • M
      KEYS: fix "ca_keys=" partial key matching · f2b3dee4
      Mimi Zohar 提交于
      The call to asymmetric_key_hex_to_key_id() from ca_keys_setup()
      silently fails with -ENOMEM.  Instead of dynamically allocating
      memory from a __setup function, this patch defines a variable
      and calls __asymmetric_key_hex_to_key_id(), a new helper function,
      directly.
      
      This bug was introduced by 'commit 46963b77 ("KEYS: Overhaul
      key identification when searching for asymmetric keys")'.
      
      Changelog:
      - for clarification, rename hexlen to asciihexlen in
        asymmetric_key_hex_to_key_id()
      - add size argument to __asymmetric_key_hex_to_key_id() - David Howells
      - inline __asymmetric_key_hex_to_key_id() - David Howells
      - remove duplicate strlen() calls
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Cc: stable@vger.kernel.org # 3.18
      f2b3dee4
  23. 07 10月, 2014 2 次提交