All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zhkl0228.impersonator.SecureRandomWrap Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package com.github.zhkl0228.impersonator;

import org.bouncycastle.tls.ClientHello;

import java.io.IOException;
import java.security.SecureRandom;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

class SecureRandomWrap extends SecureRandom implements Impersonator {

    private final Impersonator impersonator;

    SecureRandomWrap(Impersonator impersonator) {
        this.impersonator = impersonator;
    }

    @Override
    public byte[] generateSeed(int numBytes) {
        byte[] seed = new byte[numBytes];
        ThreadLocalRandom.current().nextBytes(seed);
        return seed;
    }

    @Override
    public void nextBytes(byte[] bytes) {
        ThreadLocalRandom.current().nextBytes(bytes);
    }

    @Override
    public int[] getCipherSuites() {
        return impersonator.getCipherSuites();
    }

    @Override
    public void onEstablishSession(Map clientExtensions) throws IOException {
        impersonator.onEstablishSession(clientExtensions);
    }

    @Override
    public void onSendClientHelloMessage(ClientHello clientHello, Map clientExtensions) throws IOException {
        impersonator.onSendClientHelloMessage(clientHello, clientExtensions);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy