PublicKey loadKey(String key) throws NoSuchAlgorithmException, InvalidKeySpecException {
        SSHPublicKeyHolder sshPublicKeyHolder = new SSHPublicKeyHolder();

        byte[] keyByteArray = Base64.getDecoder().decode(key);
        int keyByteArrayCursor = 0;

        byte[] tmpData = new byte[4];
        int tmpCursor = 0;

        boolean getLengthMode = true;
        while (keyByteArrayCursor < keyByteArray.length) {
            if (getLengthMode) {
                if (tmpCursor < 4) {
                    tmpData[tmpCursor] = keyByteArray[keyByteArrayCursor];
                    tmpCursor++;
                    keyByteArrayCursor++;
                    continue;
                } else {
                    tmpCursor = 0;
                    getLengthMode = false;
                    tmpData = new byte[byteArrayToInt(tmpData)];
                }
            }
            tmpData[tmpCursor] = keyByteArray[keyByteArrayCursor];
            tmpCursor++;
            keyByteArrayCursor++;
            if (tmpCursor == tmpData.length) {
                sshPublicKeyHolder.push(tmpData);
                getLengthMode = true;
                tmpData = new byte[4];
                tmpCursor = 0;
            }
        }

        return sshPublicKeyHolder.toPublicKey();
    }
@Test
    public void verifyAllTypesOfPublicKeys() throws IOException {
        final Map<String, String> keys = new LinkedHashMap<>();
        InputStream knownHosts = getClass().getResourceAsStream("/known_hosts_types");
        assertNotNull(knownHosts);
        IoUtils.readAllLines(knownHosts).forEach(l -> {
            String[] tab = l.split(" ");
            if (l.startsWith("#")) {
                return;
            }
            keys.put(tab[1], tab[2]);
        });

        ResourceBasedSSHKeyVerifier verifier = new ResourceBasedSSHKeyVerifier(null, null);
        keys.forEach((type, data) -> {
            LOG.info("Checking key {}", type);
            try {
                PublicKey publicKey = verifier.loadKey(data);
                assertNotNull(publicKey);
            } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        });
    }