• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CYASSL_MSG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CYASSL_MSG函数的典型用法代码示例。如果您正苦于以下问题:C++ CYASSL_MSG函数的具体用法?C++ CYASSL_MSG怎么用?C++ CYASSL_MSG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CYASSL_MSG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Sha512Hash

int Sha512Hash(const byte* data, word32 len, byte* hash)
{
    int ret = 0;
#ifdef CYASSL_SMALL_STACK
    Sha512* sha512;
#else
    Sha512 sha512[1];
#endif

#ifdef CYASSL_SMALL_STACK
    sha512 = (Sha512*)XMALLOC(sizeof(Sha512), NULL, DYNAMIC_TYPE_TMP_BUFFER);
    if (sha512 == NULL)
        return MEMORY_E;
#endif
    
    if ((ret = InitSha512(sha512)) != 0) {
        CYASSL_MSG("InitSha512 failed");
    }
    else if ((ret = Sha512Update(sha512, data, len)) != 0) {
        CYASSL_MSG("Sha512Update failed");
    }
    else if ((ret = Sha512Final(sha512, hash)) != 0) {
        CYASSL_MSG("Sha512Final failed");
    }
    
#ifdef CYASSL_SMALL_STACK
    XFREE(sha512, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif
    
    return ret;
}
开发者ID:Eppo791906066,项目名称:cyassl,代码行数:31,代码来源:sha512.c


示例2: RsaUnPad

static word32 RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
                       byte **output, byte padValue)
{
    word32 maxOutputLen = (pkcsBlockLen > 10) ? (pkcsBlockLen - 10) : 0,
           invalid = 0,
           i = 1,
           outputLen;

    if (pkcsBlock[0] != 0x0) /* skip past zero */
        invalid = 1;
    pkcsBlock++; pkcsBlockLen--;

    /* Require block type padValue */
    invalid = (pkcsBlock[0] != padValue) || invalid;

    /* skip past the padding until we find the separator */
    while (i<pkcsBlockLen && pkcsBlock[i++]) { /* null body */
        }
    if(!(i==pkcsBlockLen || pkcsBlock[i-1]==0)) {
        CYASSL_MSG("RsaUnPad error, bad formatting");
        return 0;
    }

    outputLen = pkcsBlockLen - i;
    invalid = (outputLen > maxOutputLen) || invalid;

    if (invalid) {
        CYASSL_MSG("RsaUnPad error, bad formatting");
        return 0;
    }

    *output = (byte *)(pkcsBlock + i);
    return outputLen;
}
开发者ID:agoragames,项目名称:cyassl,代码行数:34,代码来源:rsa.c


示例3: Sha384Hash

int Sha384Hash(const byte* data, word32 len, byte* hash)
{
    int ret = 0;
#ifdef CYASSL_SMALL_STACK
    Sha384* sha384;
#else
    Sha384 sha384[1];
#endif

#ifdef CYASSL_SMALL_STACK
    sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER);
    if (sha384 == NULL)
        return MEMORY_E;
#endif

    if ((ret = InitSha384(sha384)) != 0) {
        CYASSL_MSG("InitSha384 failed");
    }
    else if ((ret = Sha384Update(sha384, data, len)) != 0) {
        CYASSL_MSG("Sha384Update failed");
    }
    else if ((ret = Sha384Final(sha384, hash)) != 0) {
        CYASSL_MSG("Sha384Final failed");
    }

#ifdef CYASSL_SMALL_STACK
    XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

    return ret;
}
开发者ID:Eppo791906066,项目名称:cyassl,代码行数:31,代码来源:sha512.c


示例4: Arc4CaviumProcess

static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
                              word32 length)
{
    word   offset = 0;
    word32 requestId;

    while (length > CYASSL_MAX_16BIT) {
        word16 slen = (word16)CYASSL_MAX_16BIT;
        if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
                          slen, (byte*)in + offset, out + offset, &requestId,
                          arc4->devId) != 0) {
            CYASSL_MSG("Bad Cavium Arc4 Encrypt");
        }
        length -= CYASSL_MAX_16BIT;
        offset += CYASSL_MAX_16BIT;
    }
    if (length) {
        word16 slen = (word16)length;
        if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
                          slen, (byte*)in + offset, out + offset, &requestId,
                          arc4->devId) != 0) {
            CYASSL_MSG("Bad Cavium Arc4 Encrypt");
        }
    }
}
开发者ID:Difrex,项目名称:OpenSAN2,代码行数:25,代码来源:arc4.c


示例5: FreeCRL

/* Free all CRL resources */
void FreeCRL(CYASSL_CRL* crl, int dynamic)
{
    CRL_Entry* tmp = crl->crlList;

    CYASSL_ENTER("FreeCRL");

    if (crl->monitors[0].path)
        XFREE(crl->monitors[0].path, NULL, DYNAMIC_TYPE_CRL_MONITOR);

    if (crl->monitors[1].path)
        XFREE(crl->monitors[1].path, NULL, DYNAMIC_TYPE_CRL_MONITOR);

    while(tmp) {
        CRL_Entry* next = tmp->next;
        FreeCRL_Entry(tmp);
        XFREE(tmp, NULL, DYNAMIC_TYPE_CRL_ENTRY);
        tmp = next;
    }	

#ifdef HAVE_CRL_MONITOR
    if (crl->tid != 0) {
        CYASSL_MSG("stopping monitor thread");
        if (StopMonitor(crl->mfd) == 0)
            pthread_join(crl->tid, NULL);
        else {
            CYASSL_MSG("stop monitor failed, cancel instead");
            pthread_cancel(crl->tid);
        }
    }
#endif
    FreeMutex(&crl->crlLock);
    if (dynamic)   /* free self */
        XFREE(crl, NULL, DYNAMIC_TYPE_CRL);
}
开发者ID:Nathanrauch,项目名称:cyassl,代码行数:35,代码来源:crl.c


示例6: find_ocsp_entry

static OCSP_Entry* find_ocsp_entry(CYASSL_OCSP* ocsp, DecodedCert* cert)
{
    OCSP_Entry* entry = ocsp->ocspList;

    while (entry)
    {
        if (XMEMCMP(entry->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE) == 0
            && XMEMCMP(entry->issuerKeyHash, cert->issuerKeyHash,
                                                        SHA_DIGEST_SIZE) == 0)
        {
            CYASSL_MSG("Found OCSP responder");
            break;
        }
        else
        {
            entry = entry->next;
        }
    }

    if (entry == NULL)
    {
        CYASSL_MSG("Add a new OCSP entry");
        entry = (OCSP_Entry*)XMALLOC(sizeof(OCSP_Entry),
                                                NULL, DYNAMIC_TYPE_OCSP_ENTRY);
        if (entry != NULL)
        {
            InitOCSP_Entry(entry, cert);
            entry->next = ocsp->ocspList;
            ocsp->ocspList = entry;
        }
    }

    return entry;
}
开发者ID:EvertYing,项目名称:cyassl,代码行数:34,代码来源:ocsp.c


示例7: AddCRL

/* Add Decoded CRL, 0 on success */
static int AddCRL(CYASSL_CRL* crl, DecodedCRL* dcrl)
{
    CRL_Entry* crle;

    CYASSL_ENTER("AddCRL");

    crle = (CRL_Entry*)XMALLOC(sizeof(CRL_Entry), NULL, DYNAMIC_TYPE_CRL_ENTRY);
    if (crle == NULL) {
        CYASSL_MSG("alloc CRL Entry failed");
        return -1;
    }

    if (InitCRL_Entry(crle, dcrl) < 0) {
        CYASSL_MSG("Init CRL Entry failed");
        XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
        return -1;
    }

    if (LockMutex(&crl->crlLock) != 0) {
        CYASSL_MSG("LockMutex failed");
        FreeCRL_Entry(crle);
        XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
        return BAD_MUTEX_E;
    }
    crle->next = crl->crlList;
    crl->crlList = crle;
    UnLockMutex(&crl->crlLock);

    return 0;
}
开发者ID:Nathanrauch,项目名称:cyassl,代码行数:31,代码来源:crl.c


示例8: Des3_CaviumCbcDecrypt

static void Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
                                  word32 length)
{
    word32 requestId;
    word   offset = 0;

    while (length > CYASSL_MAX_16BIT) {
        word16 slen = (word16)CYASSL_MAX_16BIT;
        XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE, DES_BLOCK_SIZE);
        if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
                           CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
                           (byte*)des3->reg, (byte*)des3->key[0], &requestId,
                           des3->devId) != 0) {
            CYASSL_MSG("Bad Cavium 3Des Decrypt");
        }
        length -= CYASSL_MAX_16BIT;
        offset += CYASSL_MAX_16BIT;
        XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
    }
    if (length) {
        word16 slen = (word16)length;
        XMEMCPY(des3->tmp, in + offset + slen - DES_BLOCK_SIZE,DES_BLOCK_SIZE);
        if (CspDecrypt3Des(CAVIUM_BLOCKING, des3->contextHandle,
                           CAVIUM_NO_UPDATE, slen, (byte*)in+offset, out+offset,
                           (byte*)des3->reg, (byte*)des3->key[0], &requestId,
                           des3->devId) != 0) {
            CYASSL_MSG("Bad Cavium 3Des Decrypt");
        }
        XMEMCPY(des3->reg, des3->tmp, DES_BLOCK_SIZE);
    }
}
开发者ID:tomsparrow25,项目名称:wifisdk_for_wm,代码行数:31,代码来源:des3.c


示例9: Sha256Hash

int Sha256Hash(const byte* data, word32 len, byte* hash)
{
    int ret = 0;
#ifdef CYASSL_SMALL_STACK
    Sha256* sha256;
#else
    Sha256 sha256[1];
#endif

#ifdef CYASSL_SMALL_STACK
    sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER);
    if (sha256 == NULL)
        return MEMORY_E;
#endif

    if ((ret = InitSha256(sha256)) != 0) {
        CYASSL_MSG("InitSha256 failed");
    }
    else if ((ret = Sha256Update(sha256, data, len)) != 0) {
        CYASSL_MSG("Sha256Update failed");
    }
    else if ((ret = Sha256Final(sha256, hash)) != 0) {
        CYASSL_MSG("Sha256Final failed");
    }

#ifdef CYASSL_SMALL_STACK
    XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

    return ret;
}
开发者ID:Eppo791906066,项目名称:cyassl,代码行数:31,代码来源:sha256.c


示例10: HmacCaviumUpdate

static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
{
    word16 add = (word16)length;
    word32 total;
    byte*  tmp;

    if (length > CYASSL_MAX_16BIT) {
        CYASSL_MSG("Too big msg for cavium hmac");
        return;
    }

    if (hmac->innerHashKeyed == 0) {  /* starting new */
        hmac->dataLen        = 0;
        hmac->innerHashKeyed = 1;
    }

    total = add + hmac->dataLen;
    if (total > CYASSL_MAX_16BIT) {
        CYASSL_MSG("Too big msg for cavium hmac");
        return;
    }

    tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP);
    if (tmp == NULL) {
        CYASSL_MSG("Out of memory for cavium update");
        return;
    }
    if (hmac->dataLen)
        XMEMCPY(tmp, hmac->data,  hmac->dataLen);
    XMEMCPY(tmp + hmac->dataLen, msg, add);
        
    hmac->dataLen += add;
    XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP);
    hmac->data = tmp;
}
开发者ID:Nathanrauch,项目名称:cyassl,代码行数:35,代码来源:hmac.c


示例11: http_ocsp_transaction

static int http_ocsp_transaction(CYASSL_OCSP* ocsp, DecodedCert* cert,
                        byte* ocspReqBuf, int ocspReqSz, byte** ocspRespBuf)
{
    SOCKET_T sfd = -1;
    byte httpBuf[SCRATCH_BUFFER_SIZE];
    int httpBufSz = SCRATCH_BUFFER_SIZE;
    char domainName[80], path[80];
    int port, ocspRespSz;

    if (ocsp->useOverrideUrl || cert->extAuthInfo == NULL) {
        if (ocsp->overrideName != NULL) {
            XMEMCPY(domainName, ocsp->overrideName, 80);
            XMEMCPY(path, ocsp->overridePath, 80);
            port = ocsp->overridePort;
        } else
            return OCSP_NEED_URL;
    } else {
        if (!decode_url((const char*)cert->extAuthInfo, cert->extAuthInfoSz,
                                                    domainName, path, &port))
            return OCSP_NEED_URL;
    }

    httpBufSz = build_http_request(domainName, path, ocspReqSz,
                                                        httpBuf, httpBufSz);

    tcp_connect(&sfd, domainName, port);
    if (sfd > 0) {
        int written;
        written = (int)write(sfd, httpBuf, httpBufSz);
        if (written == httpBufSz) {
            written = (int)write(sfd, ocspReqBuf, ocspReqSz);
            if (written == ocspReqSz) {
                httpBufSz = (int)read(sfd, httpBuf, SCRATCH_BUFFER_SIZE);
                if (httpBufSz > 0) {
                    ocspRespSz = decode_http_response(httpBuf, httpBufSz,
                        ocspRespBuf);
                }
            }
        }
        close(sfd);
        if (ocspRespSz == 0) {
            CYASSL_MSG("HTTP response was not OK, no OCSP response");
            return OCSP_LOOKUP_FAIL;
        }
    } else {
        CYASSL_MSG("OCSP Responder connection failed");
        return OCSP_LOOKUP_FAIL;
    }

    return ocspRespSz;
}
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:51,代码来源:ocsp.c


示例12: BufferLoadCRL

/* Load CRL File of type, SSL_SUCCESS on ok */
int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type)
{
    int          ret = SSL_SUCCESS;
    const byte*  myBuffer = buff;    /* if DER ok, otherwise switch */
    buffer       der;
    DecodedCRL   dcrl;

    der.buffer = NULL;

    CYASSL_ENTER("BufferLoadCRL");

    if (crl == NULL || buff == NULL || sz == 0)
        return BAD_FUNC_ARG;

    if (type == SSL_FILETYPE_PEM) {
        int eccKey = 0;   /* not used */
        EncryptedInfo info;
        info.ctx = NULL;

        ret = PemToDer(buff, sz, CRL_TYPE, &der, NULL, &info, &eccKey);
        if (ret == 0) {
            myBuffer = der.buffer;
            sz = der.length;
        }
        else {
            CYASSL_MSG("Pem to Der failed");
            return -1;
        }
    }

    InitDecodedCRL(&dcrl);
    ret = ParseCRL(&dcrl, myBuffer, (word32)sz, crl->cm);
    if (ret != 0) {
        CYASSL_MSG("ParseCRL error");
    }
    else {
        ret = AddCRL(crl, &dcrl);
        if (ret != 0) {
            CYASSL_MSG("AddCRL error");
        }
    }
    FreeDecodedCRL(&dcrl);

    if (der.buffer)
        XFREE(der.buffer, NULL, DYNAMIC_TYPE_CRL);

    if (ret == 0)
        return SSL_SUCCESS;  /* convert */
    return ret;
}
开发者ID:Nathanrauch,项目名称:cyassl,代码行数:51,代码来源:crl.c


示例13: NetX_Receive

/* The NetX receive callback
 *  return :  bytes read, or error
 */
int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx)
{
    NetX_Ctx* nxCtx = (NetX_Ctx*)ctx;
    ULONG left;
    ULONG total;
    ULONG copied = 0;
    UINT  status;

    if (nxCtx == NULL || nxCtx->nxSocket == NULL) {
        CYASSL_MSG("NetX Recv NULL parameters");
        return CYASSL_CBIO_ERR_GENERAL;
    }

    if (nxCtx->nxPacket == NULL) {
        status = nx_tcp_socket_receive(nxCtx->nxSocket, &nxCtx->nxPacket,
                                       nxCtx->nxWait);
        if (status != NX_SUCCESS) {
            CYASSL_MSG("NetX Recv receive error");
            return CYASSL_CBIO_ERR_GENERAL;
        }
    }

    if (nxCtx->nxPacket) {
        status = nx_packet_length_get(nxCtx->nxPacket, &total);
        if (status != NX_SUCCESS) {
            CYASSL_MSG("NetX Recv length get error");
            return CYASSL_CBIO_ERR_GENERAL;
        }

        left = total - nxCtx->nxOffset;
        status = nx_packet_data_extract_offset(nxCtx->nxPacket, nxCtx->nxOffset,
                                               buf, sz, &copied);
        if (status != NX_SUCCESS) {
            CYASSL_MSG("NetX Recv data extract offset error");
            return CYASSL_CBIO_ERR_GENERAL;
        }

        nxCtx->nxOffset += copied;

        if (copied == left) {
            CYASSL_MSG("NetX Recv Drained packet");
            nx_packet_release(nxCtx->nxPacket);
            nxCtx->nxPacket = NULL;
            nxCtx->nxOffset = 0;
        }
    }

    return copied;
}
开发者ID:Eppo791906066,项目名称:cyassl,代码行数:52,代码来源:io.c


示例14: Cyassl_connect

/*** tcp_connect is actually associated with following syassl_tcp_connect. ***/
int Cyassl_connect(int sd, const  struct sockaddr* sa, int sz) 
{
    int ret = 0 ;
    #if defined(CYASSL_KEIL_TCP_NET)  
    
    SOCKADDR_IN addr ;

    addr = *(SOCKADDR_IN *)sa ;

    do {
        #undef connect  /* Go to KEIL TCPnet connect */
        ret = connect(sd, (SOCKADDR *)&addr, sizeof(addr)) ;
        os_dly_wait(50);
    } while(ret == SCK_EWOULDBLOCK) ;
    #ifdef DEBUG_CYASSL
    { 
        char msg[50] ;
        sprintf(msg, "BSD Connect return code: %d\n", ret) ;
        CYASSL_MSG(msg) ;
    }
    #endif
    
    #endif /* CYASSL_KEIL_TCP_NET */
    return(ret ) ;
}
开发者ID:BrianAker,项目名称:cyassl,代码行数:26,代码来源:cyassl_MDK_ARM.c


示例15: RTC_GetFullTime

struct tm *Cyassl_MDK_gmtime(const time_t *c) 
{ 
    static struct tm date ; 

  	RTC_TIME_Type RTCFullTime;
	  RTC_GetFullTime (LPC_RTC, &RTCFullTime);

    date.tm_year = RTCFullTime.YEAR + 100 ;
    date.tm_mon = RTCFullTime.MONTH - 1 ;
    date.tm_mday = RTCFullTime.DOM ;
    date.tm_hour = RTCFullTime.HOUR ;
    date.tm_min = RTCFullTime.MIN ;
    date.tm_sec = RTCFullTime.SEC ;

    #if defined(DEBUG_CYASSL) 
    {
			  extern void CYASSL_MSG(char *msg) ;
        char msg[100] ;
        sprintf(msg, "Debug::Cyassl_KEIL_gmtime(DATE=/%4d/%02d/%02d TIME=%02d:%02d:%02d)\n",
        RTCFullTime.YEAR+2000,  RTCFullTime.MONTH, RTCFullTime.DOM,
        RTCFullTime.HOUR,  RTCFullTime.MIN,  RTCFullTime.SEC) ; 
        CYASSL_MSG(msg) ;   
    }
    #endif
    
    return(&date) ;
}
开发者ID:BrianAker,项目名称:cyassl,代码行数:27,代码来源:time-LCP43xx.c


示例16: tcp_socket

static INLINE void tcp_socket(SOCKET_T* sockfd, SOCKADDR_IN_T* addr,
                              const char* peer, word16 port)
{
    const char* host = peer;

    /* peer could be in human readable form */
    if (peer != INADDR_ANY && isalpha(peer[0])) {
        struct hostent* entry = gethostbyname(peer);

        if (entry) {
            struct sockaddr_in tmp;
            memset(&tmp, 0, sizeof(struct sockaddr_in));
            memcpy(&tmp.sin_addr.s_addr, entry->h_addr_list[0],
                   entry->h_length);
            host = inet_ntoa(tmp.sin_addr);
        }
        else {
            CYASSL_MSG("no entry for host");
        }
    }

    *sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
    memset(addr, 0, sizeof(SOCKADDR_IN_T));

    addr->sin_family = AF_INET_V;
    addr->sin_port = htons(port);
    if (host == INADDR_ANY)
        addr->sin_addr.s_addr = INADDR_ANY;
    else
        addr->sin_addr.s_addr = inet_addr(host);
}
开发者ID:bohrasd,项目名称:windowsrtdev,代码行数:31,代码来源:ocsp.c


示例17: RTC_GetTime

struct tm *Cyassl_MDK_gmtime(const time_t *c) 
{ 

    RTC_TimeTypeDef RTC_Time ;
    RTC_DateTypeDef RTC_Date ;
    static struct tm date ; 

    RTC_GetTime(RTC_Format_BIN, &RTC_Time) ;
    RTC_GetDate(RTC_Format_BIN, &RTC_Date) ;

    date.tm_year = RTC_Date.RTC_Year + 100 ;
    date.tm_mon = RTC_Date.RTC_Month - 1 ;
    date.tm_mday = RTC_Date.RTC_Date ;
    date.tm_hour = RTC_Time.RTC_Hours ;
    date.tm_min = RTC_Time.RTC_Minutes ;
    date.tm_sec = RTC_Time.RTC_Seconds ;

    #if defined(DEBUG_CYASSL) 
    {
        char msg[100] ;
        sprintf(msg, "Debug::Cyassl_KEIL_gmtime(DATE=/%4d/%02d/%02d TIME=%02d:%02d:%02d)\n",
        RTC_Date.RTC_Year+2000,  RTC_Date.RTC_Month, RTC_Date.RTC_Date,
        RTC_Time.RTC_Hours,  RTC_Time.RTC_Minutes,  RTC_Time.RTC_Seconds) ; 
        CYASSL_MSG(msg) ;   
    }
    #endif
    
    return(&date) ;
}
开发者ID:EvertYing,项目名称:cyassl,代码行数:29,代码来源:time-STM32F2xx.c


示例18: SetPrefix

/* true or false, zero for error */
static int SetPrefix(byte* sha_input, int idx)
{
    switch (idx) {
    case 0:
        XMEMCPY(sha_input, "A", 1);
        break;
    case 1:
        XMEMCPY(sha_input, "BB", 2);
        break;
    case 2:
        XMEMCPY(sha_input, "CCC", 3);
        break;
    case 3:
        XMEMCPY(sha_input, "DDDD", 4);
        break;
    case 4:
        XMEMCPY(sha_input, "EEEEE", 5);
        break;
    case 5:
        XMEMCPY(sha_input, "FFFFFF", 6);
        break;
    case 6:
        XMEMCPY(sha_input, "GGGGGGG", 7);
        break;
    default:
        CYASSL_MSG("Set Prefix error, bad input");
        return 0; 
    }
    return 1;
}
开发者ID:agoragames,项目名称:cyassl,代码行数:31,代码来源:keys.c


示例19: ShaHash

int ShaHash(const byte* data, word32 len, byte* hash)
{
    int ret = 0;
#ifdef CYASSL_SMALL_STACK
    Sha* sha;
#else
    Sha sha[1];
#endif

#ifdef CYASSL_SMALL_STACK
    sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
    if (sha == NULL)
        return MEMORY_E;
#endif

    if ((ret = InitSha(sha)) != 0) {
        CYASSL_MSG("InitSha failed");
    }
    else {
        ShaUpdate(sha, data, len);
        ShaFinal(sha, hash);
    }

#ifdef CYASSL_SMALL_STACK
    XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

    return ret;
}
开发者ID:AskDrCatcher,项目名称:FreeRTOS,代码行数:29,代码来源:sha.c


示例20: EmbedGenerateCookie

/* The DTLS Generate Cookie callback
 *  return : number of bytes copied into buf, or error
 */
int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx)
{
    int sd = ssl->wfd;
    struct sockaddr_storage peer;
    XSOCKLENT peerSz = sizeof(peer);
    byte digest[SHA_DIGEST_SIZE];
    int  ret = 0;

    (void)ctx;

    XMEMSET(&peer, 0, sizeof(peer));
    if (getpeername(sd, (struct sockaddr*)&peer, &peerSz) != 0) {
        CYASSL_MSG("getpeername failed in EmbedGenerateCookie");
        return GEN_COOKIE_E;
    }

    ret = ShaHash((byte*)&peer, peerSz, digest);
    if (ret != 0)
        return ret;

    if (sz > SHA_DIGEST_SIZE)
        sz = SHA_DIGEST_SIZE;
    XMEMCPY(buf, digest, sz);

    return sz;
}
开发者ID:Eppo791906066,项目名称:cyassl,代码行数:29,代码来源:io.c



注:本文中的CYASSL_MSG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CYGACC_CALL_IF_SET_CONSOLE_COMM函数代码示例发布时间:2022-05-30
下一篇:
C++ CYASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap