crypto: ansi_cprng - enforce key != seed in fips mode

Apparently, NIST is tightening up its requirements for FIPS validation
with respect to RNGs. Its always been required that in fips mode, the
ansi cprng not be fed key and seed material that was identical, but
they're now interpreting FIPS 140-2, section AS07.09 as requiring that
the implementation itself must enforce the requirement. Easy fix, we
just do a memcmp of key and seed in fips_cprng_reset and call it a day.

v2: Per Neil's advice, ensure slen is sufficiently long before we
compare key and seed to avoid looking at potentially unallocated mem.

CC: Stephan Mueller <smueller@atsec.com>
CC: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Unlink and free instances when deleted

We leak the crypto instance when we unregister an instance with
crypto_del_alg(). Therefore we introduce crypto_unregister_instance()
to unlink the crypto instance from the template's instances list and
to free the recources of the instance properly.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Conflicts:
	crypto/crypto_user.c
Revert "crypto: Unlink and free instances when deleted"

This reverts commit e2a4a7b9b7f323b943e414ce5d19f0bd4af33327.
atomic: use <linux/atomic.h>

This allows us to move duplicated code in <asm/atomic.h>
(atomic_inc_not_zero() for now) to <linux/atomic.h>

Signed-off-by: Arun Sharma <asharma@fb.com>
Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David Miller <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Conflicts:
	arch/alpha/include/asm/atomic.h
	arch/alpha/include/asm/local.h
	arch/alpha/kernel/perf_event.c
	arch/alpha/kernel/smp.c
	arch/alpha/lib/dec_and_lock.c
	arch/arm/mach-at91/pm.c
	arch/arm/mach-bcmring/dma.c
	arch/arm/mach-cns3xxx/include/mach/pm.h
	arch/arm/mach-cns3xxx/pm.c
	arch/arm/mach-omap1/pm.c
	arch/arm/mach-s3c2440/clock.c
	arch/arm/mach-s3c2440/s3c2442.c
	arch/arm/mach-s3c2440/s3c244x-clock.c
	arch/avr32/include/asm/atomic.h
	arch/blackfin/include/asm/atomic.h
	arch/blackfin/include/asm/dma.h
	arch/blackfin/include/asm/ipipe.h
	arch/blackfin/include/asm/spinlock.h
	arch/blackfin/kernel/ftrace.c
	arch/blackfin/kernel/ipipe.c
	arch/blackfin/kernel/nmi.c
	arch/blackfin/mach-common/smp.c
	arch/cris/arch-v32/drivers/cryptocop.c
	arch/cris/arch-v32/kernel/smp.c
	arch/cris/include/asm/atomic.h
	arch/cris/include/asm/bitops.h
	arch/cris/kernel/process.c
	arch/frv/include/asm/atomic.h
	arch/frv/include/asm/hardirq.h
	arch/frv/kernel/irq.c
	arch/h8300/include/asm/atomic.h
	arch/ia64/include/asm/atomic.h
	arch/ia64/include/asm/processor.h
	arch/ia64/include/asm/spinlock.h
	arch/ia64/kernel/smp.c
	arch/ia64/kernel/smpboot.c
	arch/ia64/kernel/uncached.c
	arch/m32r/include/asm/atomic.h
	arch/m32r/include/asm/mmu_context.h
	arch/m32r/include/asm/spinlock.h
	arch/m32r/kernel/smp.c
	arch/m32r/kernel/traps.c
	arch/m68k/include/asm/atomic.h
	arch/microblaze/include/asm/mmu_context_mm.h
	arch/microblaze/include/asm/prom.h
	arch/mips/include/asm/atomic.h
	arch/mips/include/asm/hw_irq.h
	arch/mips/include/asm/local.h
	arch/mips/include/asm/smp.h
	arch/mips/kernel/irq.c
	arch/mips/kernel/mips-mt.c
	arch/mips/kernel/rtlx.c
	arch/mips/kernel/smp-cmp.c
	arch/mips/kernel/smp-mt.c
	arch/mips/kernel/smp.c
	arch/mips/kernel/smtc-proc.c
	arch/mips/kernel/smtc.c
	arch/mips/kernel/sync-r4k.c
	arch/mips/kernel/vpe.c
	arch/mips/mipssim/sim_smtc.c
	arch/mips/sgi-ip27/ip27-nmi.c
	arch/mn10300/include/asm/atomic.h
	arch/mn10300/include/asm/mmu_context.h
	arch/mn10300/include/asm/spinlock.h
	arch/mn10300/include/asm/system.h
	arch/mn10300/kernel/mn10300-watchdog.c
	arch/mn10300/kernel/traps.c
	arch/mn10300/mm/misalignment.c
	arch/mn10300/proc-mn2ws0050/proc-init.c
	arch/parisc/include/asm/atomic.h
	arch/parisc/include/asm/bitops.h
	arch/parisc/include/asm/mmu_context.h
	arch/parisc/kernel/parisc_ksyms.c
	arch/parisc/kernel/smp.c
	arch/parisc/kernel/traps.c
	arch/parisc/lib/bitops.c
	arch/powerpc/include/asm/atomic.h
	arch/powerpc/include/asm/emulated_ops.h
	arch/powerpc/include/asm/irq.h
	arch/powerpc/include/asm/local.h
	arch/powerpc/include/asm/prom.h
	arch/powerpc/kernel/of_platform.c
	arch/powerpc/kernel/ppc_ksyms.c
	arch/powerpc/kernel/rtas.c
	arch/powerpc/kernel/rtasd.c
	arch/powerpc/kernel/smp-tbsync.c
	arch/powerpc/kernel/smp.c
	arch/powerpc/platforms/83xx/km83xx.c
	arch/powerpc/platforms/83xx/mpc832x_mds.c
	arch/powerpc/platforms/83xx/mpc834x_itx.c
	arch/powerpc/platforms/83xx/mpc834x_mds.c
	arch/powerpc/platforms/83xx/mpc836x_mds.c
	arch/powerpc/platforms/83xx/sbc834x.c
	arch/powerpc/platforms/85xx/mpc85xx_cds.c
	arch/powerpc/platforms/85xx/mpc85xx_mds.c
	arch/powerpc/platforms/85xx/sbc8548.c
	arch/powerpc/platforms/cell/cpufreq_spudemand.c
	arch/powerpc/platforms/cell/smp.c
	arch/powerpc/platforms/cell/spufs/context.c
	arch/powerpc/platforms/chrp/smp.c
	arch/powerpc/platforms/iseries/smp.c
	arch/powerpc/platforms/powermac/backlight.c
	arch/powerpc/platforms/powermac/smp.c
	arch/powerpc/platforms/pseries/eeh.c
	arch/powerpc/platforms/pseries/eeh_cache.c
	arch/powerpc/platforms/pseries/smp.c
	arch/powerpc/sysdev/fsl_soc.c
	arch/powerpc/sysdev/tsi108_dev.c
	arch/s390/include/asm/atomic.h
	arch/s390/kernel/dis.c
	arch/s390/kernel/traps.c
	arch/sh/include/asm/atomic.h
	arch/sh/include/asm/hw_irq.h
	arch/sh/include/asm/smp.h
	arch/sh/kernel/idle.c
	arch/sh/kernel/smp.c
	arch/sh/kernel/traps_64.c
	arch/sh/kernel/unwinder.c
	arch/sparc/include/asm/atomic_32.h
	arch/sparc/include/asm/atomic_64.h
	arch/sparc/include/asm/prom.h
	arch/sparc/include/asm/smp_32.h
	arch/sparc/include/asm/smp_64.h
	arch/sparc/kernel/irq_64.c
	arch/sparc/kernel/leon_smp.c
	arch/sparc/kernel/perf_event.c
	arch/sparc/kernel/smp_32.c
	arch/sparc/kernel/smp_64.c
	arch/sparc/lib/atomic32.c
	arch/tile/include/asm/atomic.h
	arch/tile/include/asm/atomic_32.h
	arch/tile/include/asm/atomic_64.h
	arch/tile/include/asm/bitops_32.h
	arch/tile/include/asm/bitops_64.h
	arch/tile/include/asm/spinlock_32.h
	arch/tile/kernel/intvec_32.S
	arch/tile/lib/atomic_32.c
	arch/tile/lib/atomic_asm_32.S
	arch/x86/ia32/sys_ia32.c
	arch/x86/include/asm/apic.h
	arch/x86/include/asm/atomic.h
	arch/x86/include/asm/hw_irq.h
	arch/x86/include/asm/local.h
	arch/x86/include/asm/mce.h
	arch/x86/include/asm/mmu_context.h
	arch/x86/include/asm/prom.h
	arch/x86/include/asm/spinlock.h
	arch/x86/include/asm/thread_info.h
	arch/x86/kernel/amd_gart_64.c
	arch/x86/kernel/apic/apic.c
	arch/x86/kernel/apic/es7000_32.c
	arch/x86/kernel/i8259.c
	arch/x86/kernel/irqinit.c
	arch/x86/kernel/traps.c
	arch/x86/kvm/lapic.c
	arch/x86/kvm/timer.c
	arch/x86/lib/atomic64_32.c
	arch/x86/mm/mmio-mod.c
	arch/xtensa/include/asm/atomic.h
	arch/xtensa/kernel/process.c
	drivers/connector/cn_proc.c
	drivers/md/dm-crypt.c
	include/linux/netdevice.h
	lib/atomic64.c
	lib/crc32.c
Fix derp merges.
crypto: sha1 - export sha1_update for reuse

Export the update function as crypto_sha1_update() to not have the need
to reimplement the same algorithm for each SHA-1 implementation. This
way the generic SHA-1 implementation can be used as fallback for other
implementations that fail to run under certain circumstances, like the
need for an FPU context while executing in IRQ context.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add a flag to identify crypto instances

The upcomming crypto user configuration api needs to identify
crypto instances. This patch adds a flag that is set if the
algorithm is an instance that is build from templates.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Export crypto_remove_spawns

The upcomming crypto usrerspace configuration api needs
to remove the spawns on top on an algorithm, so export
crypto_remove_spawns.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Export crypto_remove_final

The upcomming crypto usrerspace configuration api needs
to remove the spawns on top on an algorithm, so export
crypto_remove_final.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace configuration API

This patch adds a basic userspace configuration API for the crypto layer.
With this it is possible to instantiate, remove and to show crypto
algorithms from userspace.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add a report function pointer to crypto_type

We add a report function pointer to struct crypto_type. This function
pointer is used from the crypto userspace configuration API to report
crypto algorithms to userspace.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for larval type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for shash type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for ahash type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for blkcipher type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for ablkcipher type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for givcipher type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for aead type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for nivaead type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto: Add userspace report for pcompress type algorithms

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>