key1024.c
上传用户:qiulin1960
上传日期:2013-10-16
资源大小:2844k
文件大小:4k
源码类别:

Windows CE

开发平台:

Windows_Unix

  1. /*++
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright (c) 2001. Samsung Electronics, co. ltd  All rights reserved.
  7. Module Name:  
  8. Abstract:
  9.     Debug routines
  10. rev:
  11. 2002.4.3 : First S3C2410 version (SOC)
  12. 2002.1.28 : CE.NET port (kwangyoon LEE, kwangyoon@samsung.com)
  13. Notes:
  14. This file is only needed if run-time DLL and EXE signature checking is turned on. 
  15. The public key below should correspond to the private key used to sign the
  16. executables
  17. --*/
  18. const unsigned char g_bSignPublicKeyBlob[] = {
  19.     0x06,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x04,0x00,0x00,
  20.     0x01,0x00,0x01,0x00,0x51,0xea,0xee,0xba,0x4f,0xe6,0xf4,0x87,0x44,0x7e,0x88,0xb7,
  21.     0x70,0x9d,0x05,0xf2,0xe2,0x91,0x08,0xb9,0x92,0x95,0xa7,0x76,0xe2,0xd2,0xc1,0x5a,
  22.     0x3b,0x0f,0x38,0x0a,0x5f,0x99,0xde,0x5c,0xa0,0x36,0xd3,0x03,0xca,0xd3,0x3e,0x81,
  23.     0xea,0x8d,0x60,0x43,0x12,0x21,0xf2,0x8f,0x81,0x26,0x78,0xe3,0x51,0x22,0x0b,0xee,
  24.     0x6c,0x63,0x2e,0xa8,0xf6,0x6c,0xbc,0xa1,0x41,0x03,0xf7,0xb6,0x84,0x29,0x46,0xe7,
  25.     0xfd,0xd7,0x33,0xf6,0x86,0xeb,0x08,0xe1,0x50,0xb0,0x81,0xbf,0xa2,0x91,0x6a,0xcd,
  26.     0xd0,0x32,0xb6,0x9a,0x5b,0x51,0x85,0xdd,0xab,0x90,0x17,0x9a,0xcd,0x64,0x1c,0x48,
  27.     0x16,0xc3,0xb4,0x03,0xa1,0xa7,0x15,0xf6,0x6f,0x29,0x0e,0xf7,0x87,0xda,0xc0,0x59,
  28.     0x55,0x0c,0x84,0x87
  29. };
  30. typedef BOOL (* OEMLoadInit_t)(LPWSTR lpszName);
  31. typedef DWORD (* OEMLoadModule_t)(LPBYTE lpData, DWORD cbData);
  32. // The following two kernel function pointers should be initialized in the OAL
  33. extern OEMLoadInit_t pOEMLoadInit;      // implemented by OEMLoadInit()
  34. extern OEMLoadModule_t pOEMLoadModule;  // implemented by OEMLoadModule()
  35. // LoadAuth library routines
  36. extern BOOL InitPubKey(const BYTE *KeyBlob, DWORD cbKeyBlob);
  37. extern BOOL CertifyModuleInit(void);
  38. extern BOOL CertifyModule(PBYTE pbBlock, DWORD cbBlock);
  39. extern BOOL CertifyModuleFinal(PBYTE *ppbSignData, PDWORD pcbSignData);
  40. // called once for each RAM executable module, to initialize signature checking
  41. BOOL OEMLoadInit(LPWSTR lpszName)
  42. {
  43.     return CertifyModuleInit();
  44. }
  45. // called one or more times after OemLoadInit
  46. DWORD OEMLoadModule(LPBYTE lpData, DWORD cbData)
  47. {
  48.     if (cbData)
  49.     {
  50.         // process module bytes
  51.         return CertifyModule(lpData, cbData);
  52.     }
  53.     else
  54.     {
  55.         // final call
  56.         DWORD dwTrustLevel = OEM_CERTIFY_FALSE;
  57.         LPBYTE pSignedData;
  58.         DWORD cbSignedData;
  59.         BOOL fRet = CertifyModuleFinal(&pSignedData, &cbSignedData);
  60.         if (fRet)
  61.         {
  62.             // the file has a valid signature
  63.             // we expect the trust level to be returned as signed data
  64.             if (cbSignedData < sizeof(CHAR))
  65.                 fRet = FALSE;
  66.             else
  67.             switch (*pSignedData)
  68.             {
  69.                 case 'T' :
  70.                     dwTrustLevel = OEM_CERTIFY_TRUST;
  71.                     break;
  72.                 case 'R' :
  73.                     dwTrustLevel = OEM_CERTIFY_RUN;
  74.                     break;
  75.                 default:
  76.                     dwTrustLevel = OEM_CERTIFY_FALSE;
  77.                     break;
  78.             }
  79.         }
  80.         #ifdef DEBUG
  81.         if (!fRet)
  82.         lpWriteDebugStringFunc(TEXT("OEMLoadModule:signature check failed.rn"));
  83.         #endif
  84.         // return one of the OEM_CERTIFY levels
  85.         return dwTrustLevel;
  86.     }
  87. }