Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2000 Intel Corporation
  3. Module Name:
  4. crypto.c
  5. Abstract:
  6. Add support for IEEE Node address generation when there is
  7. not a SNP-compliant NIC attached.
  8. Revision History
  9. ** Intel 2000 Update for EFI 1.0
  10. ** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
  11. ** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
  12. ** Digital Equipment Corporation, Maynard, Mass.
  13. ** To anyone who acknowledges that this file is provided AS IS
  14. ** without any express or implied warranty: permission to use, copy,
  15. ** modify, and distribute this file for any purpose is hereby
  16. ** granted without fee, provided that the above copyright notices and
  17. ** this notice appears in all source code copies, and that none of
  18. ** the names of Open Software Foundation, Inc., Hewlett-Packard
  19. ** Company, or Digital Equipment Corporation be used in advertising
  20. ** or publicity pertaining to distribution of the software without
  21. ** specific, written prior permission. Neither Open Software
  22. ** Foundation, Inc., Hewlett-Packard Company, nor Digital Equipment
  23. ** Corporation makes any representations about the suitability of
  24. ** this software for any purpose.
  25. */
  26. #include "efi.h"
  27. #include "efilib.h"
  28. #include "md5.h"
  29. #define HASHLEN 16
  30. void GenNodeID(
  31. unsigned char *pDataBuf,
  32. long cData,
  33. UINT8 NodeID[]
  34. )
  35. {
  36. int i, j;
  37. unsigned char Hash[HASHLEN];
  38. MD5_CTX context;
  39. MD5Init (&context);
  40. MD5Update (&context, pDataBuf, cData);
  41. MD5Final (&context);
  42. for (j = 0; j<6; j++) {
  43. NodeID[j]=0;
  44. }
  45. for (i = 0,j = 0; i < HASHLEN; i++) {
  46. NodeID[j++] ^= Hash[i];
  47. if (j == 6) {
  48. j = 0;
  49. }
  50. }
  51. NodeID[0] |= 0x80; // set the multicast bit
  52. }