Coder Social home page Coder Social logo

mite-note's People

Contributors

litianjue avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

mite-note's Issues

markTests

int test_sm2_enc()
{
    EC_KEY *key1;
    EC_GROUP    *group1;
    int nid,ret;

    key1 = EC_KEY_new();
    if(!key1)
        return 0;

    int nid = NID_sm2p256v1;
    group1 = EC_GROUP_new_by_curve_name(nid);
    if(group1 == NULL)
        return 0;

    ret = EC_KEY_set_group(key1,group1);
    if(ret != 1)
        return 0;

    ret = EC_KEY_generate_key(key1);

    //EC_KEY_print_fp(stdout,key1,0);
    /*---- ----*/

    printf("----加密测试----\n");
    char tmp_buf[48] = {0};
    memset(tmp_buf,'1',48);

    char out_buf[48+128] = {0};
    int buf_size = 48 +128;

    if(!SM2_encrypt_with_recommended(out_buf,&buf_size,
                (const unsigned char *)tmp_buf,sizeof(tmp_buf),key1)) {
        printf("SM2 Encryp ERROR !!!\n");
        return -1;
    }
    else
    {
        printf("SM2 Encrypt Result[%d] :\n",buf_size);
        //print_hex(out_buf,buf_size);
        printf("----测试成功----\n\n");
    }

    printf("----解密测试----\n");
    unsigned char msg[128] = {0};
    size_t msglen = 0;
    if(!SM2_decrypt_with_recommended(msg,&msglen,out_buf,buf_size,key1))
    {
        printf("解密失败!!!\n");
        return -1;
    }else {
        printf("SM2 Decrypt Result[%d] :\n",msglen);
        //print_hex(msg,msglen);
        printf("----测试成功----\n\n");
    }

    return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.