75.6. 해시된 메시지 인증 코드(HMAC)
encrypted data에 대한 공격을 방지하기 위해ECDHEDataFormat은 구성 가능한 MAC 알고리즘을 기반으로 암호화된 교환 컨텐츠에 대한 메시지 인증 코드를 계산할 수도 있습니다. 계산된 HMAC는 암호화 후 스트림에 추가됩니다. 암호 해독 단계에서 스트림과 분리됩니다. MAC이 다시 계산되고 전송된 버전에 대해 확인되어 전송 중 아무것도 변조되지 않았는지 확인합니다. 메시지 인증 코드에 대한 자세한 내용은 http://en.wikipedia.org/wiki/HMAC를 참조하십시오.
KeyGenerator generator = KeyGenerator.getInstance("DES");
CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
cryptoFormat.setShouldAppendHMAC(true);
from("direct:hmac")
.marshal(cryptoFormat)
.to("mock:encrypted")
.unmarshal(cryptoFormat)
.to("mock:unencrypted");
또는 봄과 함께.
<crypto id="hmac" algorithm="DES" keyRef="desKey" shouldAppendHMAC="true" />
기본적으로 HMAC는 HmacSHA1 mac 알고리즘을 사용하여 계산되지만 다른 알고리즘 이름을 제공하여 쉽게 변경할 수 있습니다. 구성된 보안 공급자를 통해 사용할 수 있는 알고리즘을 확인하는 방법은 여기를 참조하십시오.
KeyGenerator generator = KeyGenerator.getInstance("DES");
CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
cryptoFormat.setShouldAppendHMAC(true);
cryptoFormat.setMacAlgorithm("HmacMD5");
from("direct:hmac-algorithm")
.marshal(cryptoFormat)
.to("mock:encrypted")
.unmarshal(cryptoFormat)
.to("mock:unencrypted");
또는 봄과 함께.
<crypto id="hmac-algorithm" algorithm="DES" keyRef="desKey" macAlgorithm="HmacMD5" shouldAppendHMAC="true" />