Add detection for corrupt TPM token objects to opencryptoki

Currently, opencryptoki will happily try and allocate huge buffers
when a file is corrupted and contains an incorrect length.  This
change adds a check to see that the length of the requested object is
less than the size of the whole file.  If not, then an error is
generated.

BUG=chromium-os:24853
TEST=corrupted a file in .tpm directory, and correctly detected it.

Change-Id: Id1f8a4bbec9e417b33d63c7e89ff623c0f4fa0fe
1 file changed