密钥管理修改

This commit is contained in:
liulu 2024-11-06 15:24:39 +08:00
parent 666cc96799
commit 65c690de48
4 changed files with 17 additions and 3 deletions

View File

@ -14,9 +14,10 @@ import java.util.Objects;
@AllArgsConstructor
public enum KeyAlg {
SM1(KeyCategory.SYM_KEY, "SM1", "国密SM1"),
SM4(KeyCategory.SYM_KEY, "SM4", "国密SM4"),
SM2(KeyCategory.ASYM_KEY, "SM2", "国密SM2"),
SM1(KeyCategory.SYM_KEY, "SM1", "SM1"),
SM4(KeyCategory.SYM_KEY, "SM4", "SM4"),
SM2(KeyCategory.ASYM_KEY, "SM2", "SM2"),
RSA(KeyCategory.ASYM_KEY, "RSA", "RSA"),
;
private final KeyCategory category;
private final String code;

View File

@ -24,5 +24,16 @@ public interface SpKeyRecordMapper extends BaseMapper<KeyRecord> {
);
}
default KeyRecord selectByPubKey(String pubKey) {
if (pubKey == null || pubKey.length() != 128) {
return null;
}
return selectOne(
new LambdaQueryWrapper<KeyRecord>()
.eq(KeyRecord::getPubIdx, pubKey.substring(0, 8))
.lt(KeyRecord::getPubKey, pubKey)
);
}
}

View File

@ -18,6 +18,7 @@ public class KeyRecord {
private String keyIndex;
private String keyData;
private String pubIdx;
private String pubKey;
private String checkAlg;
private String checkValue;

View File

@ -292,6 +292,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
byte[] pubKeyBytes = eccKey.getPubKey().getPubKeyBytes();
record.setPubKey(Hex.toHexString(pubKeyBytes));
record.setPubIdx(record.getPubKey().substring(0, 8));
}
return record;
}