p_256_curvepara.cc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /******************************************************************************
  2. *
  3. * Copyright 2006-2015 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /*******************************************************************************
  19. *
  20. * This file contains simple pairing algorithms
  21. *
  22. ******************************************************************************/
  23. #include <string.h>
  24. #include "p_256_ecc_pp.h"
  25. void p_256_init_curve(uint32_t keyLength) {
  26. elliptic_curve_t* ec;
  27. if (keyLength == KEY_LENGTH_DWORDS_P256) {
  28. ec = &curve_p256;
  29. ec->p[7] = 0xFFFFFFFF;
  30. ec->p[6] = 0x00000001;
  31. ec->p[5] = 0x0;
  32. ec->p[4] = 0x0;
  33. ec->p[3] = 0x0;
  34. ec->p[2] = 0xFFFFFFFF;
  35. ec->p[1] = 0xFFFFFFFF;
  36. ec->p[0] = 0xFFFFFFFF;
  37. memset(ec->omega, 0, KEY_LENGTH_DWORDS_P256);
  38. memset(ec->a, 0, KEY_LENGTH_DWORDS_P256);
  39. ec->a_minus3 = true;
  40. // b
  41. ec->b[7] = 0x5ac635d8;
  42. ec->b[6] = 0xaa3a93e7;
  43. ec->b[5] = 0xb3ebbd55;
  44. ec->b[4] = 0x769886bc;
  45. ec->b[3] = 0x651d06b0;
  46. ec->b[2] = 0xcc53b0f6;
  47. ec->b[1] = 0x3bce3c3e;
  48. ec->b[0] = 0x27d2604b;
  49. // base point
  50. ec->G.x[7] = 0x6b17d1f2;
  51. ec->G.x[6] = 0xe12c4247;
  52. ec->G.x[5] = 0xf8bce6e5;
  53. ec->G.x[4] = 0x63a440f2;
  54. ec->G.x[3] = 0x77037d81;
  55. ec->G.x[2] = 0x2deb33a0;
  56. ec->G.x[1] = 0xf4a13945;
  57. ec->G.x[0] = 0xd898c296;
  58. ec->G.y[7] = 0x4fe342e2;
  59. ec->G.y[6] = 0xfe1a7f9b;
  60. ec->G.y[5] = 0x8ee7eb4a;
  61. ec->G.y[4] = 0x7c0f9e16;
  62. ec->G.y[3] = 0x2bce3357;
  63. ec->G.y[2] = 0x6b315ece;
  64. ec->G.y[1] = 0xcbb64068;
  65. ec->G.y[0] = 0x37bf51f5;
  66. }
  67. }