ln/tests/testinc_ln_bolt8.cpp
//name: transport-responder act3 bad version test
transport-responder act3 bad version test
transport - responder act3 bad version test
TEST_F(bolt8test, responder_act3_bad_version)
{
    bool ret;
    ln_noise_t noise;
    const uint8_t LS_PRIV[] = {
        0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
        0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
        0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
        0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
    };
    ln_node_setkey(LS_PRIV);
    ret = ln_noise_handshake_init(&noise, NULL);
    ASSERT_TRUE(ret);
    struct bolt8_t *pBolt = (struct bolt8_t *)noise.p_handshake;
    ASSERT_EQ(WAIT_ACT_ONE, pBolt->state);
    const uint8_t EPRIV[] = {
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
        0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
    };
    const uint8_t EPUB[] = {
        0x02, 0x46, 0x6d, 0x7f, 0xca, 0xe5, 0x63, 0xe5,
        0xcb, 0x09, 0xa0, 0xd1, 0x87, 0x0b, 0xb5, 0x80,
        0x34, 0x48, 0x04, 0x61, 0x78, 0x79, 0xa1, 0x49,
        0x49, 0xcf, 0x22, 0x28, 0x5f, 0x1b, 0xae, 0x3f,
        0x27,
    };
    memcpy(pBolt->e.priv, EPRIV, sizeof(EPRIV));
    memcpy(pBolt->e.pub, EPUB, sizeof(EPUB));
    const uint8_t INPUT_1R[50] = {
        0x00, 0x03, 0x63, 0x60, 0xe8, 0x56, 0x31, 0x0c,
        0xe5, 0xd2, 0x94, 0xe8, 0xbe, 0x33, 0xfc, 0x80,
        0x70, 0x77, 0xdc, 0x56, 0xac, 0x80, 0xd9, 0x5d,
        0x9c, 0xd4, 0xdd, 0xbd, 0x21, 0x32, 0x5e, 0xff,
        0x73, 0xf7, 0x0d, 0xf6, 0x08, 0x65, 0x51, 0x15,
        0x1f, 0x58, 0xb8, 0xaf, 0xe6, 0xc1, 0x95, 0x78,
        0x2c, 0x6a,
    };
    utl_buf_t buf = UTL_BUF_INIT;
    utl_buf_alloccopy(&buf, INPUT_1R, sizeof(INPUT_1R));
    ret = ln_noise_handshake_recv(&noise, &buf);
    ASSERT_TRUE(ret);
    ASSERT_EQ(WAIT_ACT_THREE, pBolt->state);
    ASSERT_TRUE(ln_noise_handshake_state(&noise));
    const uint8_t OUTPUT_1R[50] = {
        0x00, 0x02, 0x46, 0x6d, 0x7f, 0xca, 0xe5, 0x63,
        0xe5, 0xcb, 0x09, 0xa0, 0xd1, 0x87, 0x0b, 0xb5,
        0x80, 0x34, 0x48, 0x04, 0x61, 0x78, 0x79, 0xa1,
        0x49, 0x49, 0xcf, 0x22, 0x28, 0x5f, 0x1b, 0xae,
        0x3f, 0x27, 0x6e, 0x24, 0x70, 0xb9, 0x3a, 0xac,
        0x58, 0x3c, 0x9e, 0xf6, 0xea, 0xfc, 0xa3, 0xf7,
        0x30, 0xae,
    };
    ASSERT_EQ(sizeof(OUTPUT_1R), buf.len);
    ASSERT_EQ(0, memcmp(OUTPUT_1R, buf.buf, sizeof(OUTPUT_1R)));
    utl_buf_free(&buf);
    const uint8_t INPUT_3R[66] = {
       0x01, 0xb9, 0xe3, 0xa7, 0x02, 0xe9, 0x3e, 0x3a,
       0x99, 0x48, 0xc2, 0xed, 0x6e, 0x5f, 0xd7, 0x59,
       0x0a, 0x6e, 0x1c, 0x3a, 0x03, 0x44, 0xcf, 0xc9,
       0xd5, 0xb5, 0x73, 0x57, 0x04, 0x9a, 0xa2, 0x23,
       0x55, 0x36, 0x1a, 0xa0, 0x2e, 0x55, 0xa8, 0xfc,
       0x28, 0xfe, 0xf5, 0xbd, 0x6d, 0x71, 0xad, 0x0c,
       0x38, 0x22, 0x8d, 0xc6, 0x8b, 0x1c, 0x46, 0x62,
       0x63, 0xb4, 0x7f, 0xdf, 0x31, 0xe5, 0x60, 0xe1,
       0x39, 0xba,
    };
    utl_buf_alloccopy(&buf, INPUT_3R, sizeof(INPUT_3R));
    ret = ln_noise_handshake_recv(&noise, &buf);
    ASSERT_FALSE(ret);
    ASSERT_EQ(0, noise.p_handshake);
    ASSERT_FALSE(ln_noise_handshake_state(&noise));
    utl_buf_free(&buf);
    ret = ln_noise_handshake_recv(&noise, &buf);
    ASSERT_FALSE(ret);
}
TEST_F ( bolt8test , responder_act3_bad_version ) { bool ret ; ln_noise_t noise ; const uint8_t LS_PRIV [ ] = { 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , 0x21 , } ; ln_node_setkey ( LS_PRIV ) ; ret = ln_noise_handshake_init ( & noise , NULL ) ; ASSERT_TRUE ( ret ) ; struct bolt8_t * pBolt = ( struct bolt8_t * ) noise . p_handshake ; ASSERT_EQ ( WAIT_ACT_ONE , pBolt -> state ) ; const uint8_t EPRIV [ ] = { 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , 0x22 , } ; const uint8_t EPUB [ ] = { 0x02 , 0x46 , 0x6d , 0x7f , 0xca , 0xe5 , 0x63 , 0xe5 , 0xcb , 0x09 , 0xa0 , 0xd1 , 0x87 , 0x0b , 0xb5 , 0x80 , 0x34 , 0x48 , 0x04 , 0x61 , 0x78 , 0x79 , 0xa1 , 0x49 , 0x49 , 0xcf , 0x22 , 0x28 , 0x5f , 0x1b , 0xae , 0x3f , 0x27 , } ; memcpy ( pBolt -> e . priv , EPRIV , sizeof ( EPRIV ) ) ; memcpy ( pBolt -> e . pub , EPUB , sizeof ( EPUB ) ) ; const uint8_t INPUT_1R [ 50 ] = { 0x00 , 0x03 , 0x63 , 0x60 , 0xe8 , 0x56 , 0x31 , 0x0c , 0xe5 , 0xd2 , 0x94 , 0xe8 , 0xbe , 0x33 , 0xfc , 0x80 , 0x70 , 0x77 , 0xdc , 0x56 , 0xac , 0x80 , 0xd9 , 0x5d , 0x9c , 0xd4 , 0xdd , 0xbd , 0x21 , 0x32 , 0x5e , 0xff , 0x73 , 0xf7 , 0x0d , 0xf6 , 0x08 , 0x65 , 0x51 , 0x15 , 0x1f , 0x58 , 0xb8 , 0xaf , 0xe6 , 0xc1 , 0x95 , 0x78 , 0x2c , 0x6a , } ; utl_buf_t buf = UTL_BUF_INIT ; utl_buf_alloccopy ( & buf , INPUT_1R , sizeof ( INPUT_1R ) ) ; ret = ln_noise_handshake_recv ( & noise , & buf ) ; ASSERT_TRUE ( ret ) ; ASSERT_EQ ( WAIT_ACT_THREE , pBolt -> state ) ; ASSERT_TRUE ( ln_noise_handshake_state ( & noise ) ) ; const uint8_t OUTPUT_1R [ 50 ] = { 0x00 , 0x02 , 0x46 , 0x6d , 0x7f , 0xca , 0xe5 , 0x63 , 0xe5 , 0xcb , 0x09 , 0xa0 , 0xd1 , 0x87 , 0x0b , 0xb5 , 0x80 , 0x34 , 0x48 , 0x04 , 0x61 , 0x78 , 0x79 , 0xa1 , 0x49 , 0x49 , 0xcf , 0x22 , 0x28 , 0x5f , 0x1b , 0xae , 0x3f , 0x27 , 0x6e , 0x24 , 0x70 , 0xb9 , 0x3a , 0xac , 0x58 , 0x3c , 0x9e , 0xf6 , 0xea , 0xfc , 0xa3 , 0xf7 , 0x30 , 0xae , } ; ASSERT_EQ ( sizeof ( OUTPUT_1R ) , buf . len ) ; ASSERT_EQ ( 0 , memcmp ( OUTPUT_1R , buf . buf , sizeof ( OUTPUT_1R ) ) ) ; utl_buf_free ( & buf ) ; const uint8_t INPUT_3R [ 66 ] = { 0x01 , 0xb9 , 0xe3 , 0xa7 , 0x02 , 0xe9 , 0x3e , 0x3a , 0x99 , 0x48 , 0xc2 , 0xed , 0x6e , 0x5f , 0xd7 , 0x59 , 0x0a , 0x6e , 0x1c , 0x3a , 0x03 , 0x44 , 0xcf , 0xc9 , 0xd5 , 0xb5 , 0x73 , 0x57 , 0x04 , 0x9a , 0xa2 , 0x23 , 0x55 , 0x36 , 0x1a , 0xa0 , 0x2e , 0x55 , 0xa8 , 0xfc , 0x28 , 0xfe , 0xf5 , 0xbd , 0x6d , 0x71 , 0xad , 0x0c , 0x38 , 0x22 , 0x8d , 0xc6 , 0x8b , 0x1c , 0x46 , 0x62 , 0x63 , 0xb4 , 0x7f , 0xdf , 0x31 , 0xe5 , 0x60 , 0xe1 , 0x39 , 0xba , } ; utl_buf_alloccopy ( & buf , INPUT_3R , sizeof ( INPUT_3R ) ) ; ret = ln_noise_handshake_recv ( & noise , & buf ) ; ASSERT_FALSE ( ret ) ; ASSERT_EQ ( 0 , noise . p_handshake ) ; ASSERT_FALSE ( ln_noise_handshake_state ( & noise ) ) ; utl_buf_free ( & buf ) ; ret = ln_noise_handshake_recv ( & noise , & buf ) ; ASSERT_FALSE ( ret ) ; }
name: transport-responder act3 bad version test
name : transport - responder act3 bad version test
//vector //ephemeralの差し替え //Act One Receive and Act Two Send //input: 0x00036360e856310ce5d294e8be33fc807077dc56ac80d95d9cd4ddbd21325eff73f70df6086551151f58b8afe6c195782c6a //output: 0x0002466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276e2470b93aac583c9ef6eafca3f730ae //Act Three Receive //input: 0x01b9e3a702e93e3a9948c2ed6e5fd7590a6e1c3a0344cfc9d5b57357049aa22355361aa02e55a8fc28fef5bd6d71ad0c38228dc68b1c466263b47fdf31e560e139ba