Commit 05b70bf0 authored by Josh Ji's avatar Josh Ji

test case

parent 865b39ea
package com.prlab.idpserver;
import org.apache.tomcat.util.buf.HexUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.batch.BatchProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import java.sql.Types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SpringBootTest
class IdpServerApplicationTests {
@Autowired
JdbcTemplate jdbcTemplate;
@Test
void contextLoads() {
jdbcTemplate.execute("set block_encryption_mode='aes-256-cbc';");
jdbcTemplate.execute("set @zero=unhex('00000000000000000000000000000000');");
String hmac1 = "BB69BE49C8205A6D518C22A011F03811E871D2F28B2889150A9E8B0249868D943BE0343F40420F482DAD335B59BA178B";
byte[] bytes = HexUtils.fromHexString(hmac1);
String hmac_cx_plus_1 ="select * from identities " +
"where ?=aes_encrypt(unhex(sha2(concat(unhex(hex(idx)),unhex(conv(conv(hex(cx), 16, 10)+1, 10, 16))), 256)), sharedsecret, @zero);";
List<Map<String, Object>> list = jdbcTemplate.queryForList(hmac_cx_plus_1, new Object[]{bytes}, new int[]{Types.VARBINARY});
list.forEach(m->{
m.forEach((k, v)->{
if(v instanceof byte[])
System.out.println(k+": "+HexUtils.toHexString((byte[])v));
else
System.out.println(k+": "+v);
});
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment