1. 29 7月, 2014 1 次提交
  2. 28 7月, 2014 2 次提交
  3. 25 7月, 2014 1 次提交
  4. 23 7月, 2014 1 次提交
  5. 19 7月, 2014 1 次提交
  6. 18 7月, 2014 1 次提交
  7. 17 7月, 2014 4 次提交
  8. 09 7月, 2014 8 次提交
  9. 08 7月, 2014 6 次提交
    • D
      PKCS#7: Provide a key type for testing PKCS#7 · 22d01afb
      David Howells 提交于
      Provide a key type for testing the PKCS#7 parser.  It is given a non-detached
      PKCS#7 message as payload:
      
      	keyctl padd pkcs7_test a @s <stuff.pkcs7
      
      The PKCS#7 wrapper is validated against the trusted certificates available and
      then stripped off.  If successful, the key can be read, which will give the
      data content of the PKCS#7 message.
      
      A suitable message can be created by running make on the attached Makefile.
      This will produce a file called stuff.pkcs7 for test loading.  The key3.x509
      file should be put into the kernel source tree before it is built and
      converted to DER form:
      
      	openssl x509 -in .../pkcs7/key3.x509 -outform DER -out key3.x509
      
      ###############################################################################
      #
      # Create a pkcs7 message and sign it twice
      #
      #	openssl x509 -text -inform PEM -noout -in key2.x509
      #
      ###############################################################################
      stuff.pkcs7: stuff.txt key2.priv key2.x509 key4.priv key4.x509 certs
      	$(RM) $@
      	openssl smime -sign \
      		-signer key2.x509 \
      		-inkey key2.priv \
      		-signer key4.x509 \
      		-inkey key4.priv \
      		-in stuff.txt \
      		-certfile certs \
      		-out $@ -binary -outform DER -nodetach
      	openssl pkcs7 -inform DER -in stuff.pkcs7  -print_certs -noout
      	openssl asn1parse -inform DER -in stuff.pkcs7  -i >out
      
      stuff.txt:
      	echo "The quick red fox jumped over the lazy brown dog" >stuff.txt
      
      certs: key1.x509 key2.x509 key3.x509 key4.x509
      	cat key{1,3}.x509 >$@
      
      ###############################################################################
      #
      # Generate a signed key
      #
      #	openssl x509 -text -inform PEM -noout -in key2.x509
      #
      ###############################################################################
      key2.x509: key2.x509_unsigned key1.priv key1.x509
      	openssl x509 \
      		-req -in key2.x509_unsigned \
      		-out key2.x509 \
      		-extfile key2.genkey -extensions myexts \
      		-CA key1.x509 \
      		-CAkey key1.priv \
      		-CAcreateserial
      
      key2.priv key2.x509_unsigned: key2.genkey
      	openssl req -new -nodes -utf8 -sha1 -days 36500 \
      		-batch -outform PEM \
      		-config key2.genkey \
      		-keyout key2.priv \
      		-out key2.x509_unsigned
      
      key2.genkey:
      	@echo Generating X.509 key generation config
      	@echo  >$@ "[ req ]"
      	@echo >>$@ "default_bits = 4096"
      	@echo >>$@ "distinguished_name = req_distinguished_name"
      	@echo >>$@ "prompt = no"
      	@echo >>$@ "string_mask = utf8only"
      	@echo >>$@ "x509_extensions = myexts"
      	@echo >>$@
      	@echo >>$@ "[ req_distinguished_name ]"
      	@echo >>$@ "O = Magrathea"
      	@echo >>$@ "CN = PKCS7 key 2"
      	@echo >>$@ "emailAddress = slartibartfast@magrathea.h2g2"
      	@echo >>$@
      	@echo >>$@ "[ myexts ]"
      	@echo >>$@ "basicConstraints=critical,CA:FALSE"
      	@echo >>$@ "keyUsage=digitalSignature"
      	@echo >>$@ "subjectKeyIdentifier=hash"
      	@echo >>$@ "authorityKeyIdentifier=keyid"
      
      ###############################################################################
      #
      # Generate a couple of signing keys
      #
      #	openssl x509 -text -inform PEM -noout -in key1.x509
      #
      ###############################################################################
      key1.x509: key1.x509_unsigned key4.priv key4.x509
      	openssl x509 \
      		-req -in key1.x509_unsigned \
      		-out key1.x509 \
      		-extfile key1.genkey -extensions myexts \
      		-CA key4.x509 \
      		-CAkey key4.priv \
      		-CAcreateserial
      
      key1.priv key1.x509_unsigned: key1.genkey
      	openssl req -new -nodes -utf8 -sha1 -days 36500 \
      		-batch -outform PEM \
      		-config key1.genkey \
      		-keyout key1.priv \
      		-out key1.x509_unsigned
      
      key1.genkey:
      	@echo Generating X.509 key generation config
      	@echo  >$@ "[ req ]"
      	@echo >>$@ "default_bits = 4096"
      	@echo >>$@ "distinguished_name = req_distinguished_name"
      	@echo >>$@ "prompt = no"
      	@echo >>$@ "string_mask = utf8only"
      	@echo >>$@ "x509_extensions = myexts"
      	@echo >>$@
      	@echo >>$@ "[ req_distinguished_name ]"
      	@echo >>$@ "O = Magrathea"
      	@echo >>$@ "CN = PKCS7 key 1"
      	@echo >>$@ "emailAddress = slartibartfast@magrathea.h2g2"
      	@echo >>$@
      	@echo >>$@ "[ myexts ]"
      	@echo >>$@ "basicConstraints=critical,CA:TRUE"
      	@echo >>$@ "keyUsage=digitalSignature,keyCertSign"
      	@echo >>$@ "subjectKeyIdentifier=hash"
      	@echo >>$@ "authorityKeyIdentifier=keyid"
      
      ###############################################################################
      #
      # Generate a signed key
      #
      #	openssl x509 -text -inform PEM -noout -in key4.x509
      #
      ###############################################################################
      key4.x509: key4.x509_unsigned key3.priv key3.x509
      	openssl x509 \
      		-req -in key4.x509_unsigned \
      		-out key4.x509 \
      		-extfile key4.genkey -extensions myexts \
      		-CA key3.x509 \
      		-CAkey key3.priv \
      		-CAcreateserial
      
      key4.priv key4.x509_unsigned: key4.genkey
      	openssl req -new -nodes -utf8 -sha1 -days 36500 \
      		-batch -outform PEM \
      		-config key4.genkey \
      		-keyout key4.priv \
      		-out key4.x509_unsigned
      
      key4.genkey:
      	@echo Generating X.509 key generation config
      	@echo  >$@ "[ req ]"
      	@echo >>$@ "default_bits = 4096"
      	@echo >>$@ "distinguished_name = req_distinguished_name"
      	@echo >>$@ "prompt = no"
      	@echo >>$@ "string_mask = utf8only"
      	@echo >>$@ "x509_extensions = myexts"
      	@echo >>$@
      	@echo >>$@ "[ req_distinguished_name ]"
      	@echo >>$@ "O = Magrathea"
      	@echo >>$@ "CN = PKCS7 key 4"
      	@echo >>$@ "emailAddress = slartibartfast@magrathea.h2g2"
      	@echo >>$@
      	@echo >>$@ "[ myexts ]"
      	@echo >>$@ "basicConstraints=critical,CA:TRUE"
      	@echo >>$@ "keyUsage=digitalSignature,keyCertSign"
      	@echo >>$@ "subjectKeyIdentifier=hash"
      	@echo >>$@ "authorityKeyIdentifier=keyid"
      
      ###############################################################################
      #
      # Generate a couple of signing keys
      #
      #	openssl x509 -text -inform PEM -noout -in key3.x509
      #
      ###############################################################################
      key3.priv key3.x509: key3.genkey
      	openssl req -new -nodes -utf8 -sha1 -days 36500 \
      		-batch -x509 -outform PEM \
      		-config key3.genkey \
      		-keyout key3.priv \
      		-out key3.x509
      
      key3.genkey:
      	@echo Generating X.509 key generation config
      	@echo  >$@ "[ req ]"
      	@echo >>$@ "default_bits = 4096"
      	@echo >>$@ "distinguished_name = req_distinguished_name"
      	@echo >>$@ "prompt = no"
      	@echo >>$@ "string_mask = utf8only"
      	@echo >>$@ "x509_extensions = myexts"
      	@echo >>$@
      	@echo >>$@ "[ req_distinguished_name ]"
      	@echo >>$@ "O = Magrathea"
      	@echo >>$@ "CN = PKCS7 key 3"
      	@echo >>$@ "emailAddress = slartibartfast@magrathea.h2g2"
      	@echo >>$@
      	@echo >>$@ "[ myexts ]"
      	@echo >>$@ "basicConstraints=critical,CA:TRUE"
      	@echo >>$@ "keyUsage=digitalSignature,keyCertSign"
      	@echo >>$@ "subjectKeyIdentifier=hash"
      	@echo >>$@ "authorityKeyIdentifier=keyid"
      
      clean:
      	$(RM) *~
      	$(RM) key1.* key2.* key3.* key4.* stuff.* out certs
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      22d01afb
    • D
      PKCS#7: Find intersection between PKCS#7 message and known, trusted keys · 08815b62
      David Howells 提交于
      Find the intersection between the X.509 certificate chain contained in a PKCS#7
      message and a set of keys that we already know and trust.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      08815b62
    • D
      PKCS#7: Verify internal certificate chain · 8c76d793
      David Howells 提交于
      Verify certificate chain in the X.509 certificates contained within the PKCS#7
      message as far as possible.  If any signature that we should be able to verify
      fails, we reject the whole lot.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      8c76d793
    • D
      PKCS#7: Find the right key in the PKCS#7 key list and verify the signature · a4730357
      David Howells 提交于
      Find the appropriate key in the PKCS#7 key list and verify the signature with
      it.  There may be several keys in there forming a chain.  Any link in that
      chain or the root of that chain may be in our keyrings.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      a4730357
    • D
      PKCS#7: Digest the data in a signed-data message · 9f0d3314
      David Howells 提交于
      Digest the data in a PKCS#7 signed-data message and attach to the
      public_key_signature struct contained in the pkcs7_message struct.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      9f0d3314
    • D
      PKCS#7: Implement a parser [RFC 2315] · 2e3fadbf
      David Howells 提交于
      Implement a parser for a PKCS#7 signed-data message as described in part of
      RFC 2315.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      2e3fadbf
  10. 03 7月, 2014 1 次提交
  11. 01 7月, 2014 1 次提交
  12. 24 11月, 2013 1 次提交
    • L
      Revert "KEYS: verify a certificate is signed by a 'trusted' key" · 4c1cc40a
      Linus Torvalds 提交于
      This reverts commit 09fbc473, which
      caused the following build errors:
      
        crypto/asymmetric_keys/x509_public_key.c: In function ‘x509_key_preparse’:
        crypto/asymmetric_keys/x509_public_key.c:237:35: error: ‘system_trusted_keyring’ undeclared (first use in this function)
         ret = x509_validate_trust(cert, system_trusted_keyring);
                                         ^
        crypto/asymmetric_keys/x509_public_key.c:237:35: note: each undeclared identifier is reported only once for each function it appears in
      
      reported by Jim Davis. Mimi says:
      
       "I made the classic mistake of requesting this patch to be upstreamed
        at the last second, rather than waiting until the next open window.
      
        At this point, the best course would probably be to revert the two
        commits and fix them for the next open window"
      Reported-by: NJim Davis <jim.epost@gmail.com>
      Acked-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4c1cc40a
  13. 01 11月, 2013 1 次提交
    • D
      KEYS: The RSA public key algorithm needs to select MPILIB · dbed7141
      David Howells 提交于
      The RSA public key algorithm needs to select MPILIB directly in Kconfig as the
      'select' directive is not recursive and is thus MPILIB is not enabled by
      selecting MPILIB_EXTRA.
      
      Without this, the following errors can occur:
      
      	crypto/built-in.o: In function `RSA_verify_signature':
      	rsa.c:(.text+0x1d347): undefined reference to `mpi_get_nbits'
      	rsa.c:(.text+0x1d354): undefined reference to `mpi_get_nbits'
      	rsa.c:(.text+0x1d36e): undefined reference to `mpi_cmp_ui'
      	rsa.c:(.text+0x1d382): undefined reference to `mpi_cmp'
      	rsa.c:(.text+0x1d391): undefined reference to `mpi_alloc'
      	rsa.c:(.text+0x1d3b0): undefined reference to `mpi_powm'
      	rsa.c:(.text+0x1d3c3): undefined reference to `mpi_free'
      	rsa.c:(.text+0x1d3d8): undefined reference to `mpi_get_buffer'
      	rsa.c:(.text+0x1d4d4): undefined reference to `mpi_free'
      	rsa.c:(.text+0x1d503): undefined reference to `mpi_get_nbits'
      Reported-by: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NRandy Dunlap <rdunlap@infradead.org>
      dbed7141
  14. 26 10月, 2013 2 次提交
  15. 07 10月, 2013 1 次提交
    • J
      crypto: crypto_memneq - add equality testing of memory regions w/o timing leaks · 6bf37e5a
      James Yonan 提交于
      When comparing MAC hashes, AEAD authentication tags, or other hash
      values in the context of authentication or integrity checking, it
      is important not to leak timing information to a potential attacker,
      i.e. when communication happens over a network.
      
      Bytewise memory comparisons (such as memcmp) are usually optimized so
      that they return a nonzero value as soon as a mismatch is found. E.g,
      on x86_64/i5 for 512 bytes this can be ~50 cyc for a full mismatch
      and up to ~850 cyc for a full match (cold). This early-return behavior
      can leak timing information as a side channel, allowing an attacker to
      iteratively guess the correct result.
      
      This patch adds a new method crypto_memneq ("memory not equal to each
      other") to the crypto API that compares memory areas of the same length
      in roughly "constant time" (cache misses could change the timing, but
      since they don't reveal information about the content of the strings
      being compared, they are effectively benign). Iow, best and worst case
      behaviour take the same amount of time to complete (in contrast to
      memcmp).
      
      Note that crypto_memneq (unlike memcmp) can only be used to test for
      equality or inequality, NOT for lexicographical order. This, however,
      is not an issue for its use-cases within the crypto API.
      
      We tried to locate all of the places in the crypto API where memcmp was
      being used for authentication or integrity checking, and convert them
      over to crypto_memneq.
      
      crypto_memneq is declared noinline, placed in its own source file,
      and compiled with optimizations that might increase code size disabled
      ("Os") because a smart compiler (or LTO) might notice that the return
      value is always compared against zero/nonzero, and might then
      reintroduce the same early-return optimization that we are trying to
      avoid.
      
      Using #pragma or __attribute__ optimization annotations of the code
      for disabling optimization was avoided as it seems to be considered
      broken or unmaintained for long time in GCC [1]. Therefore, we work
      around that by specifying the compile flag for memneq.o directly in
      the Makefile. We found that this seems to be most appropriate.
      
      As we use ("Os"), this patch also provides a loop-free "fast-path" for
      frequently used 16 byte digests. Similarly to kernel library string
      functions, leave an option for future even further optimized architecture
      specific assembler implementations.
      
      This was a joint work of James Yonan and Daniel Borkmann. Also thanks
      for feedback from Florian Weimer on this and earlier proposals [2].
      
        [1] http://gcc.gnu.org/ml/gcc/2012-07/msg00211.html
        [2] https://lkml.org/lkml/2013/2/10/131Signed-off-by: NJames Yonan <james@openvpn.net>
      Signed-off-by: NDaniel Borkmann <dborkman@redhat.com>
      Cc: Florian Weimer <fw@deneb.enyo.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      6bf37e5a
  16. 26 9月, 2013 8 次提交