⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wap_crpt.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:


/*
+-----------------------------------------------------------------------------
|  File     : wap_crpt.c
+-----------------------------------------------------------------------------
|                 Copyright Condat AG 1999-2001, Berlin
|                 All rights reserved.
|
|                 This file is confidential and a trade secret of Condat AG
|                 The receipt of or possession of this file does not convey
|                 any rights to reproduce or disclose its contents or to
|                 manufacture, use, or sell anything it may describe, in
|                 whole, or in part, without the specific written consent of
|                 Condat AG.
+-----------------------------------------------------------------------------
|  Purpose :  callbacks for AUS browser, NULL, NOT IMPLEMENTED YET
|            
+----------------------------------------------------------------------------- 
*/
#ifndef WAP_CRPT_C
#define WAP_CRPT_C
#endif

#define ENTITY_WAP


/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)

#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "pcm.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "pei.h"
#include "tok.h"
#include "dti.h"      /* functionality of the dti library */

#else

#include <string.h>
#include "stddefs.h"
#include "pconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "custom.h"
#include "gsm.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "prim.h"
#include "vsi.h"
#include "pei.h"
#include "tok.h"

#endif

#include "wap.h"
#include "cus_wap.h"




#include "aapicrpt.h"
#include "capicrpt.h"

/*************************************************************
 * General functions
 *************************************************************/

/*
 * Perform necessary initialization chores, for example, seed
 * the random number generator.
 * This function must be called once before any other functions
 * in the crypto library are used.
 */
VOID CRYPTa_initialise (UINT16 id)
{
	TRACE_EVENT(">>>>> CRYPTa_initialise");
	CRYPTc_initialiseResponse(id, CRV_OK);
}

/*
 * Terminate the use of the crypto library. This function is called
 * when WTLS is being shut down. Current handles held by the user
 * (e.g., HashHandle and MasterSecretID) are no longer valid
 * after calling this function.
 */
INT16 CRYPTa_terminate (VOID)
{
  return CRV_OK;
}


/***********************************************************************
 * Crypto Methods
 ***********************************************************************/

/*
 * Retrieve lists of crypto parameters that the crypto library supports.
 * This includes cipher methods, key exchange methods, and trusted
 * certificates.
 * The response should be delivered by a call to the connector function
 * CRYPTc_getMethodsResponse. The parameter, "id",
 * should be passed back in this response.
 */
VOID CRYPTa_getMethods (UINT16 id)
{	
  CRYPTc_getMethodsResponse (id, CRV_OK, NULL, 0, NULL, 0, NULL, 0);
}


/***********************************************************************
 * Bulk encryption algorithms
 ***********************************************************************/

/*
 * Encrypt single-part data.
 * For some encryption methods, the input plaintext data has certain
 * length constraints. If these constraints are not satisfied, then
 * CRYPTa_encrypt will fail with return code CRV_DATA_LENGTH.
 * The plaintext and ciphertext can be in the same place, i.e., it is
 * OK if data and encryptedData point to the same location.
 * The ciphertext is always of the same length as the plaintext.
 */
INT16 CRYPTa_encrypt (
                      BulkCipherAlgorithm method,
                      KeyObject key,
                      BYTE *data, 
                      UINT16 dataLen,
                      BYTE *encryptedData
                     )
{
  return CRV_UNSUPPORTED_METHOD;
}

/*
 * Decrypt single-part data.
 * For some decryption methods, the input ciphertext has certain
 * length constraints. If these constraints are not satisfied, then
 * CRYPTa_decrypt will fail with return code CRV_DATA_LENGTH.
 * The ciphertext and plaintext can be in the same place, i.e., it is
 * OK if data and decryptedData point to the same location.
 * The ciphertext is always of the same length as the plaintext.
 */
INT16 CRYPTa_decrypt (
                      BulkCipherAlgorithm method,
                      KeyObject key,
                      BYTE *data, 
                      UINT16 dataLen,
                      BYTE *decryptedData
                     )
{
  return CRV_UNSUPPORTED_METHOD;
}


/***********************************************************************
 * Secure hash algorithms
 ***********************************************************************/

/*
 * Compute a hash digest of given single-part data.
 * The input data and digest output can be in the same place, i.e.,
 * it is OK if "data" and "digest" point to the same location.
 * CRYPTa_hash is equivalent to a call to CRYPTa_hashInit, followed
 * by a sequence of CRYPTa_hashUpdate operations, and terminated
 * by a call to CRYPTa_hashFinal.
 */
INT16 CRYPTa_hash (
                   HashAlgorithm alg,
                   BYTE *data, 
                   UINT16 dataLen,
                   BYTE *digest
                  )
{
  return CRV_UNSUPPORTED_METHOD;
}

/*
 * Initialize a hash operation.
 * "alg" is the hash algorithm to use, and on return "handleptr"
 * will point to a new handle to be used in subsequent operations.
 * After calling CRYPTa_hashInit, one calls CRYPTa_hashUpdate zero or
 * more times, followed by CRYPTa_hashFinal, to digest data in
 * multiple parts. The hash operation is active until one makes
 * a call to CRYPTa_hashFinal to actually obtain
 * the final piece of ciphertext. To process additional data
 * (in single or multiple parts), one must call CRYPTa_hashInit again.
 */
INT16 CRYPTa_hashInit (
                       HashAlgorithm alg,
                       HashHandle *handleptr
                      )
{
  return CRV_UNSUPPORTED_METHOD;
}

/*
 * Continue a multiple-part hash operation, processing another data part.
 * "handle" is the handle of the hash operation, "part" points to the
 * data part, and "partLen" is the length of the data part.
 * The hash operation must have been initialized with CRYPTa_hashInit.
 * A call to CRYPTa_hashUpdate which results in an error terminates
 * the current hash operation.
 */
INT16 CRYPTa_hashUpdate (
                         HashHandle handle,
                         BYTE *part, 
                         UINT16 partLen
                        )
{
  return CRV_INVALID_HANDLE;
}


/*
 * Finish a multiple-part hash operation.
 * "handle" is the handle of the hash operation, and "digest" is the location
 * that receives the computed message digest.
 * The hash operation must have been initialized with CRYPTa_hashInit.
 * A call to CRYPTa_hashFinal always terminates the active hash operation.
 */
INT16 CRYPTa_hashFinal (
                        HashHandle handle,
                        BYTE *digest
                       )
{
  return CRV_INVALID_HANDLE;
}


/***********************************************************************
 * Key exchange
 ***********************************************************************/

/*
 * Perform key exchange, using one of the methods previously
 * reported to be available.
 * Derives the master secret using the pre-master secret produced
 * by the key exchange algorithm, and the 32 random bytes
 * (ClientHello.random + ServerHello.random) supplied
 * as a parameter to this call. The master secret is kept internally in
 * the crypto library, to be used in subsequent operations.
 * The parameter "alg" is the secure hash algorithm to be used.
 * The response should be delivered by a call to the connector function
 * CRYPTc_keyExchangeResponse. The first parameter, "id",
 * should be passed back in this response.
 *
 * RSA:
 * The public key to use is either given explicitly in the parameters,
 * or must be retrieved from a certificate passed to this routine.
 * This function generates a 20-byte value consisting of the given
 * "additionalData" and 19 random bytes. It encrypts the value with
 * the given public key, and stores the result in publicValue.
 * The pre-master secret is the 20-byte value appended with the
 * given public key.
 *
 * Diffie-Hellman: calculate a pre-master secret and a public value
 * to be sent to the server side.
 * The public key to use is given explicitly in the parameters.
 * This function performs a DH calculation based on the given
 * public key and a private key kept in the crypto library.
 *
 * ECDH: calculate a pre-master secret and a public value
 * to be sent to the server side.
 * The public key to use is either given explicitly in the parameters,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -