// 
// Decompiled by Procyon v0.6.0
// 

package io.netty.handler.codec.quic;

import io.netty.util.internal.ObjectUtil;
import java.nio.ByteBuffer;
import java.security.SecureRandom;

final class SecureRandomQuicConnectionIdGenerator implements QuicConnectionIdGenerator
{
    private static final SecureRandom RANDOM;
    static final QuicConnectionIdGenerator INSTANCE;
    
    private SecureRandomQuicConnectionIdGenerator() {
    }
    
    @Override
    public ByteBuffer newId(final int length) {
        ObjectUtil.checkInRange(length, 0, this.maxConnectionIdLength(), "length");
        final byte[] bytes = new byte[length];
        SecureRandomQuicConnectionIdGenerator.RANDOM.nextBytes(bytes);
        return ByteBuffer.wrap(bytes);
    }
    
    @Override
    public ByteBuffer newId(final ByteBuffer buffer, final int length) {
        return this.newId(length);
    }
    
    @Override
    public int maxConnectionIdLength() {
        return Quiche.QUICHE_MAX_CONN_ID_LEN;
    }
    
    @Override
    public boolean isIdempotent() {
        return false;
    }
    
    static {
        RANDOM = new SecureRandom();
        INSTANCE = new SecureRandomQuicConnectionIdGenerator();
    }
}
