/**
 * @license
 * Copyright 2013 Google Inc. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Test data for verifying ECDSA. The test vectors were
 *     downloaded from http://www.nsa.gov/ia/_files/ecdsa.pdf.
 * @author thaidn@google.com (Thai Duong).
 */

goog.provide('e2e.ecc.ecdsaTestData');
goog.setTestOnly();

goog.require('e2e.ecc.PrimeCurve');


/** Test stuff */
e2e.ecc.ecdsaTestData.testVectors = [
  {
    'curve': e2e.ecc.PrimeCurve.P_256,

    'privKey': [
      0x70, 0xa1, 0x2c, 0x2d, 0xb1, 0x68, 0x45, 0xed,
      0x56, 0xff, 0x68, 0xcf, 0xc2, 0x1a, 0x47, 0x2b,
      0x3f, 0x04, 0xd7, 0xd6, 0x85, 0x1b, 0xf6, 0x34,
      0x9f, 0x2d, 0x7d, 0x5b, 0x34, 0x52, 0xb3, 0x8a],

    'pubKey': [
      // uncompressed
      0x4,
      // x
      0x81, 0x01, 0xec, 0xe4, 0x74, 0x64, 0xa6, 0xea,
      0xd7, 0x0c, 0xf6, 0x9a, 0x6e, 0x2b, 0xd3, 0xd8,
      0x86, 0x91, 0xa3, 0x26, 0x2d, 0x22, 0xcb, 0xa4,
      0xf7, 0x63, 0x5e, 0xaf, 0xf2, 0x66, 0x80, 0xa8,
      // y
      0xd8, 0xa1, 0x2b, 0xa6, 0x1d, 0x59, 0x92, 0x35,
      0xf6, 0x7d, 0x9c, 0xb4, 0xd5, 0x8f, 0x17, 0x83,
      0xd3, 0xca, 0x43, 0xe7, 0x8f, 0x0a, 0x5a, 0xba,
      0xa6, 0x24, 0x07, 0x99, 0x36, 0xc0, 0xc3, 0xa9],

    'message':
        'This is only a test message. It is 48 bytes long',

    'k': [
      0x58, 0x0e, 0xc0, 0x0d, 0x85, 0x64, 0x34, 0x33,
      0x4c, 0xef, 0x3f, 0x71, 0xec, 0xae, 0xd4, 0x96,
      0x5b, 0x12, 0xae, 0x37, 0xfa, 0x47, 0x05, 0x5b,
      0x19, 0x65, 0xc7, 0xb1, 0x34, 0xee, 0x45, 0xd0],

    'r': [
      0x72, 0x14, 0xbc, 0x96, 0x47, 0x16, 0x0b, 0xbd,
      0x39, 0xff, 0x2f, 0x80, 0x53, 0x3f, 0x5d, 0xc6,
      0xdd, 0xd7, 0x0d, 0xdf, 0x86, 0xbb, 0x81, 0x56,
      0x61, 0xe8, 0x05, 0xd5, 0xd4, 0xe6, 0xf2, 0x7c],

    's': [
      0x7d, 0x1f, 0xf9, 0x61, 0x98, 0x0f, 0x96, 0x1b,
      0xda, 0xa3, 0x23, 0x3b, 0x62, 0x09, 0xf4, 0x01,
      0x33, 0x17, 0xd3, 0xe3, 0xf9, 0xe1, 0x49, 0x35,
      0x92, 0xdb, 0xea, 0xa1, 0xaf, 0x2b, 0xc3, 0x67]
  },

  {
    'curve': e2e.ecc.PrimeCurve.P_384,

    'privKey': [
      0xc8, 0x38, 0xb8, 0x52, 0x53, 0xef, 0x8d, 0xc7,
      0x39, 0x4f, 0xa5, 0x80, 0x8a, 0x51, 0x83, 0x98,
      0x1c, 0x7d, 0xee, 0xf5, 0xa6, 0x9b, 0xa8, 0xf4,
      0xf2, 0x11, 0x7f, 0xfe, 0xa3, 0x9c, 0xfc, 0xd9,
      0x0e, 0x95, 0xf6, 0xcb, 0xc8, 0x54, 0xab, 0xac,
      0xab, 0x70, 0x1d, 0x50, 0xc1, 0xf3, 0xcf, 0x24],

    'pubKey': [
      // compressed, y is odd
      0x03,
      // x
      0x1f, 0xba, 0xc8, 0xee, 0xbd, 0x0c, 0xbf, 0x35,
      0x64, 0x0b, 0x39, 0xef, 0xe0, 0x80, 0x8d, 0xd7,
      0x74, 0xde, 0xbf, 0xf2, 0x0a, 0x2a, 0x32, 0x9e,
      0x91, 0x71, 0x3b, 0xaf, 0x7d, 0x7f, 0x3c, 0x3e,
      0x81, 0x54, 0x6d, 0x88, 0x37, 0x30, 0xbe, 0xe7,
      0xe4, 0x86, 0x78, 0xf8, 0x57, 0xb0, 0x2c, 0xa0],

    'message':
        'This is only a test message. It is 48 bytes long',

    'k': [
      0xdc, 0x6b, 0x44, 0x03, 0x69, 0x89, 0xa1, 0x96,
      0xe3, 0x9d, 0x1c, 0xda, 0xc0, 0x00, 0x81, 0x2f,
      0x4b, 0xdd, 0x8b, 0x2d, 0xb4, 0x1b, 0xb3, 0x3a,
      0xf5, 0x13, 0x72, 0x58, 0x5e, 0xbd, 0x1d, 0xb6,
      0x3f, 0x0c, 0xe8, 0x27, 0x5a, 0xa1, 0xfd, 0x45,
      0xe2, 0xd2, 0xa7, 0x35, 0xf8, 0x74, 0x93, 0x59],

    'r': [
      0xa0, 0xc2, 0x7e, 0xc8, 0x93, 0x09, 0x2d, 0xea,
      0x1e, 0x1b, 0xd2, 0xcc, 0xfe, 0xd3, 0xcf, 0x94,
      0x5c, 0x81, 0x34, 0xed, 0x0c, 0x9f, 0x81, 0x31,
      0x1a, 0x0f, 0x4a, 0x05, 0x94, 0x2d, 0xb8, 0xdb,
      0xed, 0x8d, 0xd5, 0x9f, 0x26, 0x74, 0x71, 0xd5,
      0x46, 0x2a, 0xa1, 0x4f, 0xe7, 0x2d, 0xe8, 0x56],

    's': [
      0x20, 0xab, 0x3f, 0x45, 0xb7, 0x4f, 0x10, 0xb6,
      0xe1, 0x1f, 0x96, 0xa2, 0xc8, 0xeb, 0x69, 0x4d,
      0x20, 0x6b, 0x9d, 0xda, 0x86, 0xd3, 0xc7, 0xe3,
      0x31, 0xc2, 0x6b, 0x22, 0xc9, 0x87, 0xb7, 0x53,
      0x77, 0x26, 0x57, 0x76, 0x67, 0xad, 0xad, 0xf1,
      0x68, 0xeb, 0xbe, 0x80, 0x37, 0x94, 0xa4, 0x02]
  }
];
