blob: fc2dcb9cc83b37dfd3a7f34a6c84e34117f36644 [file] [log] [blame]
Paul Crowley63ef1512018-11-28 12:48:16 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.locksettings;
18
19import android.test.AndroidTestCase;
20
21import com.android.internal.util.HexDump;
22
23public class SP800DeriveTests extends AndroidTestCase {
24 public void testFixedInput() throws Exception {
25 // CAVP: https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/key-derivation
26 byte[] keyBytes = HexDump.hexStringToByteArray(
27 "e204d6d466aad507ffaf6d6dab0a5b26"
28 + "152c9e21e764370464e360c8fbc765c6");
29 SP800Derive sk = new SP800Derive(keyBytes);
30 byte[] fixedInput = HexDump.hexStringToByteArray(
31 "7b03b98d9f94b899e591f3ef264b71b1"
32 + "93fba7043c7e953cde23bc5384bc1a62"
33 + "93580115fae3495fd845dadbd02bd645"
34 + "5cf48d0f62b33e62364a3a80");
35 byte[] res = sk.fixedInput(fixedInput);
36 assertEquals((
37 "770dfab6a6a4a4bee0257ff335213f78"
38 + "d8287b4fd537d5c1fffa956910e7c779").toUpperCase(), HexDump.toHexString(res));
39 }
40}