| | |
| | | String API_PREFIX = "/client"; |
| | | |
| | | String GET_CBCMACENCIPHER = API_PREFIX + "/getCBCMacEncipher"; |
| | | String GET_CBCMACENCIPHER_VERIFY = API_PREFIX + "/getCBCMacEncipherVerify"; |
| | | String GET_ENCRYPT = API_PREFIX + "/getEncrypt"; |
| | | String GET_DECRYPT = API_PREFIX + "/getDecrypt"; |
| | | |
| | | @PostMapping(GET_CBCMACENCIPHER) |
| | | R<CBCResultDTO> getCBCMacEncipher(@RequestParam("message")String message); |
| | | |
| | | @PostMapping(GET_CBCMACENCIPHER_VERIFY) |
| | | R<CBCResultDTO> getCBCMacEncipherVerify(@RequestParam("sm4Iv")String sm4Iv, @RequestParam("keyIndex")String keyIndex, @RequestParam("message")String message); |
| | | |
| | | @PostMapping(GET_ENCRYPT) |
| | | R<ResultDTO> getEncrypt(@RequestParam("sm4Iv")String sm4Iv, @RequestParam("keyIndex")String keyIndex, @RequestParam("message")String message); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<CBCResultDTO> getCBCMacEncipherVerify(String sm4Iv, String keyIndex, String message) { |
| | | return R.data(pwdSendService.getCBCMacEncipher(sm4Iv, keyIndex, message)); |
| | | } |
| | | |
| | | @Override |
| | | @PostMapping(GET_ENCRYPT) |
| | | public R<ResultDTO> getEncrypt(String sm4Iv, String keyIndex, String message) { |
| | | return R.data(pwdSendService.getEncrypt(sm4Iv,keyIndex,message)); |
| | |
| | | */ |
| | | CBCResultDTO getCBCMacEncipher(String message); |
| | | |
| | | CBCResultDTO getCBCMacEncipher(String sm4Iv, String keyIndex, String message); |
| | | |
| | | ResultDTO getEncrypt(String sm4Iv, String keyIndex, String message); |
| | | |
| | | ResultDTO getDecrypt(String sm4Iv, String keyIndex, String message); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CBCResultDTO getCBCMacEncipher(String sm4Iv, String keyIndex, String message) { |
| | | return pwdSendRequestUtil.getCBCMacEncipher(sm4Iv, keyIndex, message); |
| | | } |
| | | |
| | | @Override |
| | | public ResultDTO getEncrypt(String sm4Iv, String keyIndex, String message) { |
| | | return pwdSendRequestUtil.getEncrypt(sm4Iv, keyIndex, message); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * CBC加密 用户验证方法 |
| | | * |
| | | * @param message keyIndex:密钥 sm4IV:base64后的16字节字符串 maced:MAC计算值 |
| | | * @return |
| | | */ |
| | | public CBCResultDTO getCBCMacEncipher(String sm4Iv, String keyIndex, String message) { |
| | | |
| | | String url = urlPrefix + "/api/Http/scm"; |
| | | |
| | | |
| | | JSONObject jsonParm = new JSONObject(); |
| | | jsonParm.put("Action", "CBCMac"); |
| | | jsonParm.put("DeviceType", "SCM"); |
| | | |
| | | JSONObject targetJson = new JSONObject(); |
| | | targetJson.put("TimeStamp", String.valueOf(System.currentTimeMillis())); |
| | | targetJson.put("Token", getToken()); |
| | | targetJson.put("KeyIndex", keyIndex); |
| | | targetJson.put("Message", message); |
| | | targetJson.put("Sm4IV", sm4Iv); |
| | | |
| | | jsonParm.put("Target", targetJson); |
| | | |
| | | ResultDTO ret = apiRequest(url, jsonParm.toJSONString()); |
| | | |
| | | return new CBCResultDTO(getKeyIndex(), sm4Iv, ret.getData()); |
| | | } |
| | | |
| | | /** |
| | | * 加密 |
| | | * @param sm4Iv 算法为SM4时需要填写,16字节字符串 |
| | | * @param keyIndex 密钥 |