Hmac Class — netty Architecture
Architecture documentation for the Hmac class in Hmac.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5bd1a483_27e1_6efa_e106_4fe3575fc3d0["Hmac"] 493807f5_0be9_72a3_4b85_c03ae2dcde60["Hmac.java"] 5bd1a483_27e1_6efa_e106_4fe3575fc3d0 -->|defined in| 493807f5_0be9_72a3_4b85_c03ae2dcde60 0e4028c4_7d23_dcc3_8dc6_9ec7bd865208["Mac()"] 5bd1a483_27e1_6efa_e106_4fe3575fc3d0 -->|method| 0e4028c4_7d23_dcc3_8dc6_9ec7bd865208 320196ae_8dba_0a87_2a0a_7f800a5a7eb5["ByteBuffer()"] 5bd1a483_27e1_6efa_e106_4fe3575fc3d0 -->|method| 320196ae_8dba_0a87_2a0a_7f800a5a7eb5 193e525f_51f1_be2b_4c9a_609ea0a1f452["Hmac()"] 5bd1a483_27e1_6efa_e106_4fe3575fc3d0 -->|method| 193e525f_51f1_be2b_4c9a_609ea0a1f452
Relationship Graph
Source Code
codec-classes-quic/src/main/java/io/netty/handler/codec/quic/Hmac.java lines 28–67
final class Hmac {
private static final FastThreadLocal<Mac> MACS = new FastThreadLocal<Mac>() {
@Override
protected Mac initialValue() {
return newMac();
}
};
private static final String ALGORITM = "HmacSHA256";
private static final byte[] randomKey = new byte[16];
static {
new SecureRandom().nextBytes(randomKey);
}
private static Mac newMac() {
try {
SecretKeySpec keySpec = new SecretKeySpec(randomKey, ALGORITM);
Mac mac = Mac.getInstance(ALGORITM);
mac.init(keySpec);
return mac;
} catch (NoSuchAlgorithmException | InvalidKeyException exception) {
throw new IllegalStateException(exception);
}
}
static ByteBuffer sign(ByteBuffer input, int outLength) {
Mac mac = MACS.get();
mac.reset();
mac.update(input);
byte[] signBytes = mac.doFinal();
if (signBytes.length != outLength) {
signBytes = Arrays.copyOf(signBytes, outLength);
}
return ByteBuffer.wrap(signBytes);
}
private Hmac() { }
}
Source
Frequently Asked Questions
What is the Hmac class?
Hmac is a class in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/Hmac.java.
Where is Hmac defined?
Hmac is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/Hmac.java at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free