lockbox: handle an NVRAM area defined as V1 when default is V2

Handle the the case where the lockbox NVRAM area was defined with a V1
size but never finalized (e.g. defined with pre-R22 image, and upgraded
to an R22 image). To do this, fetch the NVRAM area's size during a Store
to adjust the expected format being used rather than depending on the
object initialization size. Adjusted unittests to handle the change in
call pattern, and added explicit "version downgrade" test.

BUG=chromium-os:32951
TEST=alex build, manual testing, unit tests, smoke suite.

Change-Id: I1975a32b04396d4166ce70e1bf72a80e12ff6b22
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28874
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
2 files changed