/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (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.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 * 
 * The Original Code is the Netscape security libraries.
 * 
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are 
 * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
 * Rights Reserved.
 * 
 * Contributor(s):
 * 
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License Version 2 or later (the
 * "GPL"), in which case the provisions of the GPL are applicable 
 * instead of those above.  If you wish to allow use of your 
 * version of this file only under the terms of the GPL and not to
 * allow others to use your version of this file under the MPL,
 * indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by
 * the GPL.  If you do not delete the provisions above, a recipient
 * may use your version of this file under either the MPL or the
 * GPL.
 */

/* This key is the 1024-bit test key used for speed testing of RSA private 
** key ops in OpenSSL.  We use it here for comparison purposes.
*/
#include "seccomon.h"
#include "secoidt.h"
#include "keyt.h"

#define CONST

static CONST unsigned char default_n[128] = {
0xdc,0x98,0x43,0xe8,0x3d,0x43,0x5b,0xe4,0x05,0xcd,0xd0,0xa9,0x3e,0xcb,0x83,0x75,
0xf6,0xb5,0xa5,0x9f,0x6b,0xe9,0x34,0x41,0x29,0x18,0xfa,0x6a,0x55,0x4d,0x70,0xfc,
0xec,0xae,0x87,0x38,0x0a,0x20,0xa9,0xc0,0x45,0x77,0x6e,0x57,0x60,0x57,0xf4,0xed,
0x96,0x22,0xcb,0x8f,0xe1,0x33,0x3a,0x17,0x1f,0xed,0x37,0xa5,0x6f,0xeb,0xa6,0xbc,
0x12,0x80,0x1d,0x53,0xbd,0x70,0xeb,0x21,0x76,0x3e,0xc9,0x2f,0x1a,0x45,0x24,0x82,
0xff,0xcd,0x59,0x32,0x06,0x2e,0x12,0x3b,0x23,0x78,0xed,0x12,0x3d,0xe0,0x8d,0xf9,
0x67,0x4f,0x37,0x4e,0x47,0x02,0x4c,0x2d,0xc0,0x4f,0x1f,0xb3,0x94,0xe1,0x41,0x2e,
0x2d,0x90,0x10,0xfc,0x82,0x91,0x8b,0x0f,0x22,0xd4,0xf2,0xfc,0x2c,0xab,0x53,0x55
};

static CONST unsigned char default_e[3] = { 0x01,0x00,0x01 };

static CONST unsigned char default_d[128] = {
0x2b,0xcc,0x3f,0x8f,0x58,0xba,0x8b,0x00,0x16,0xf6,0xea,0x3a,0xf0,0x30,0xd0,0x05,
0x17,0xda,0xb0,0xeb,0x9a,0x2d,0x4f,0x26,0xb0,0xd6,0x38,0xc1,0xeb,0xf5,0xd8,0x3d,
0x1f,0x70,0xf7,0x7f,0xf4,0xe2,0xcf,0x51,0x51,0x79,0x88,0xfa,0xe8,0x32,0x0e,0x7b,
0x2d,0x97,0xf2,0xfa,0xba,0x27,0xc5,0x9c,0xd9,0xc5,0xeb,0x8a,0x79,0x52,0x3c,0x64,
0x34,0x7d,0xc2,0xcf,0x28,0xc7,0x4e,0xd5,0x43,0x0b,0xd1,0xa6,0xca,0x6d,0x03,0x2d,
0x72,0x23,0xbc,0x6d,0x05,0xfa,0x16,0x09,0x2f,0x2e,0x5c,0xb6,0xee,0x74,0xdd,0xd2,
0x48,0x8e,0x36,0x0c,0x06,0x3d,0x4d,0xe5,0x10,0x82,0xeb,0x6a,0xf3,0x4b,0x9f,0xd6,
0xed,0x11,0xb1,0x6e,0xec,0xf4,0xfe,0x8e,0x75,0x94,0x20,0x2f,0xcb,0xac,0x46,0xf1
};

static CONST unsigned char default_p[64] = {
0xf9,0x8c,0xa3,0x85,0xb1,0xdd,0x29,0xaf,0x65,0xc1,0x33,0xf3,0x95,0xc5,0x52,0x68,
0x0b,0xd4,0xf1,0xe5,0x0e,0x02,0x9f,0x4f,0xfa,0x77,0xdc,0x46,0x9e,0xc7,0xa6,0xe4,
0x16,0x29,0xda,0xb0,0x07,0xcf,0x5b,0xa9,0x12,0x8a,0xdd,0x63,0x0a,0xde,0x2e,0x8c,
0x66,0x8b,0x8c,0xdc,0x19,0xa3,0x7e,0xf4,0x3b,0xd0,0x1a,0x8c,0xa4,0xc2,0xe1,0xd3
};

static CONST unsigned char default_q[64] = {
0xe2,0x4c,0x05,0xf2,0x04,0x86,0x4e,0x61,0x43,0xdb,0xb0,0xb9,0x96,0x86,0x52,0x2c,
0xca,0x8d,0x7b,0xab,0x0b,0x13,0x0d,0x7e,0x38,0x5b,0xe2,0x2e,0x7b,0x0e,0xe7,0x19,
0x99,0x38,0xe7,0xf2,0x21,0xbd,0x85,0x85,0xe3,0xfd,0x28,0x77,0x20,0x31,0x71,0x2c,
0xd0,0xff,0xfb,0x2e,0xaf,0x85,0xb4,0x86,0xca,0xf3,0xbb,0xca,0xaa,0x0f,0x95,0x37
};

static CONST unsigned char default_dModP[64] = {
0x0e,0x41,0x9a,0x95,0xe8,0xb3,0x59,0xce,0x4b,0x61,0xde,0x35,0xec,0x38,0x79,0x9c,
0xb8,0x10,0x52,0x41,0x63,0xab,0x82,0xae,0x6f,0x00,0xa9,0xf4,0xde,0xdd,0x49,0x0b,
0x7e,0xb8,0xa5,0x65,0xa9,0x0c,0x8f,0x8f,0xf9,0x1f,0x35,0xc6,0x92,0xb8,0x5e,0xb0,
0x66,0xab,0x52,0x40,0xc0,0xb6,0x36,0x6a,0x7d,0x80,0x46,0x04,0x02,0xe5,0x9f,0x41
};

static CONST unsigned char default_dModQ[64] = {
0xc0,0xad,0xcc,0x4e,0x21,0xee,0x1d,0x24,0x91,0xfb,0xa7,0x80,0x8d,0x9a,0xb6,0xb3,
0x2e,0x8f,0xc2,0xe1,0x82,0xdf,0x69,0x18,0xb4,0x71,0xff,0xa6,0x65,0xde,0xed,0x84,
0x8d,0x42,0xb7,0xb3,0x21,0x69,0x56,0x1c,0x07,0x60,0x51,0x29,0x04,0xff,0x34,0x06,
0xdd,0xb9,0x67,0x2c,0x7c,0x04,0x93,0x0e,0x46,0x15,0xbb,0x2a,0xb7,0x1b,0xe7,0x87
};

static CONST unsigned char default_qInvModP[64] = {
0x78,0xda,0x5d,0x07,0x51,0x0c,0x16,0x7a,0x9f,0x29,0x20,0x84,0x0d,0x42,0xfa,0xd7,
0x00,0xd8,0x77,0x7e,0xb0,0xb0,0x6b,0xd6,0x5b,0x53,0xb8,0x9b,0x7a,0xcd,0xc7,0x2b,
0xb8,0x6a,0x63,0xa9,0xfb,0x6f,0xa4,0x72,0xbf,0x4c,0x5d,0x00,0x14,0xba,0xfa,0x59,
0x88,0xed,0xe4,0xe0,0x8c,0xa2,0xec,0x14,0x7e,0x2d,0xe2,0xf0,0x46,0x49,0x95,0x45
};

static struct SECKEYLowPrivateKeyStr rsaPriv;

SECKEYLowPrivateKey *
getDefaultRSAPrivateKey(void)
{
    if (rsaPriv.keyType != rsaKey) {

	/* leaving arena uninitialized. It isn't used in this test. */

	rsaPriv.keyType                 = rsaKey;

	rsaPriv.u.rsa.modulus.data          =        default_n;
	rsaPriv.u.rsa.modulus.len           = sizeof default_n;

	/* leaving version uninitialized. It isn't used. */

	rsaPriv.u.rsa.publicExponent.data   =        default_e;
	rsaPriv.u.rsa.publicExponent.len    = sizeof default_e;
	rsaPriv.u.rsa.privateExponent.data  =        default_d;
	rsaPriv.u.rsa.privateExponent.len   = sizeof default_d;
	rsaPriv.u.rsa.prime[0].data         =        default_p;
	rsaPriv.u.rsa.prime[0].len          = sizeof default_p;
	rsaPriv.u.rsa.prime[1].data         =        default_q;
	rsaPriv.u.rsa.prime[1].len          = sizeof default_q;
	rsaPriv.u.rsa.primeExponent[0].data =        default_dModP;
	rsaPriv.u.rsa.primeExponent[0].len  = sizeof default_dModP;
	rsaPriv.u.rsa.primeExponent[1].data =        default_dModQ;
	rsaPriv.u.rsa.primeExponent[1].len  = sizeof default_dModQ;
	rsaPriv.u.rsa.coefficient.data      =        default_qInvModP;
	rsaPriv.u.rsa.coefficient.len       = sizeof default_qInvModP;
    }
    return &rsaPriv;
}

static struct SECKEYLowPublicKeyStr rsaPub;

SECKEYLowPublicKey *
getDefaultRSAPublicKey(void)
{
    if (rsaPub.keyType != rsaKey) {

	rsaPub.keyType			= rsaKey;

	rsaPub.u.rsa.modulus.data          =        default_n;
	rsaPub.u.rsa.modulus.len           = sizeof default_n;

	rsaPub.u.rsa.publicExponent.data   =        default_e;
	rsaPub.u.rsa.publicExponent.len    = sizeof default_e;
    }
    return &rsaPub;
}

