Esempio n. 1
0
// Check that the base point scalar multiple routine matches the generic base point routine
void base_point_test(MinTLS_NamedCurve curve)
{
    size_t const key_sz = mintls_ecdh_scalar_size(curve);
    size_t const pt_sz  = mintls_ecdh_point_size(curve);

    // Scalar representing 1 (in big endian)
    std::vector<uint8_t> one(key_sz,0);
    one[key_sz-1] = 1;

    // Extract out the base point
    std::vector<uint8_t> base_point(pt_sz);
    ASSERT_EQ(
        mintls_ecdh_base_scalar_mult(
            curve,          // (I) Curve
            &one[0],        // (I) Private Key
            one.size(),     // (I) Private Key size
            &base_point[0]  // (O) Public Key
        ),
        0
    );

    // Computer scalar multiple in two ways
    std::vector<uint8_t> scalar(key_sz,0);
    mintls_random(&scalar[0], key_sz);

    std::vector<uint8_t> point1(pt_sz);
    std::vector<uint8_t> point2(pt_sz);
    ASSERT_EQ(
        mintls_ecdh_base_scalar_mult(
            curve,          // (I) Curve
            &scalar[0],     // (I) Private Key
            scalar.size(),  // (I) Private Key Size
            &point1[0]      // (O) Public Key
        ),
        0
    );

    ASSERT_EQ(
        mintls_ecdh_scalar_mult(
            curve,              // (I) Curve
            &scalar[0],         // (I) Scalar (big endian using [5] 4.3.3)
            scalar.size(),      // (I) Scalar size
            &base_point[0],     // (I) Base point (uncompressed using [5] 4.3.6)
            base_point.size(),  // (I) Base point size
            &point2[0]          // (O) Point (uncompressed using [5] 4.3.6)
        ),
        0
    );

    EXPECT_EQ(point1,point2);
}
Esempio n. 2
0
void base_point1(double tooth_angle)
{
	base_point(tooth_angle, CLEARANCE_POINT1_TYPE);
}