Package javax.crypto

Examples of javax.crypto.ShortBufferException


    @Override
    protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException {
        int result = engineGetOutputSize(inputLen);
        if ((output.length - outputOffset) < result)
            throw new ShortBufferException();

        byte[] buf = engineDoFinal(input, inputOffset, inputLen);
        result = buf.length;
        if ((output.length - outputOffset) < result)
            throw new ShortBufferException();

        System.arraycopy(buf, 0, output, outputOffset, result);
        return result;
    }
View Full Code Here


        return inputLen;
        }
        catch (DataLengthException e)
        {
            throw new ShortBufferException(e.getMessage());
        }
    }
View Full Code Here

        {
            return cipher.processBytes(input, inputOffset, inputLen, output, outputOffset);
        }
        catch (DataLengthException e)
        {
            throw new ShortBufferException(e.getMessage());
        }
    }
View Full Code Here

    {
        byte[]  secret = bigIntToBytes(result);

        if (sharedSecret.length - offset < secret.length)
        {
            throw new ShortBufferException("ECKeyAgreement - buffer too short");
        }

        if (kdf != null)
        {
            kdf.init(new KDFParameters(secret, null));
View Full Code Here

        byte[]  secret = bigIntToBytes(result);

        if (sharedSecret.length - offset < secret.length)
        {
            throw new ShortBufferException("DHKeyAgreement - buffer too short");
        }

        System.arraycopy(secret, 0, sharedSecret, offset, secret.length);

        return secret.length;
View Full Code Here

            throw new IllegalStateException
                ("Key agreement has not been completed yet");
        }

        if (sharedSecret == null) {
            throw new ShortBufferException
                ("No buffer provided for shared secret");
        }

        BigInteger modulus = init_p;
        byte[] secret = this.y.modPow(this.x, modulus).toByteArray();

        // BigInteger.toByteArray will sometimes put a sign byte up front,
        // but we NEVER want one.
        if ((secret.length << 3) != modulus.bitLength()) {
            if ((sharedSecret.length - offset) < (secret.length - 1)) {
                throw new ShortBufferException
                    ("Buffer too short for shared secret");
            }
            System.arraycopy(secret, 1, sharedSecret, offset,
                             secret.length - 1);

            // Reset the key agreement here (not earlier!), so that people
            // can recover from ShortBufferException above without losing
            // internal state
            generateSecret = false;

            return secret.length - 1;

        } else {
            if ((sharedSecret.length - offset) < secret.length) {
                throw new ShortBufferException
                    ("Buffer too short to hold shared secret");
            }
            System.arraycopy(secret, 0, sharedSecret, offset, secret.length);

            // Reset the key agreement here (not earlier!), so that people
View Full Code Here

    {
        if (in == null)
            return;

        if ((off + len) > in.length) {
            throw new ShortBufferException("Buffer too small to hold padding");
        }

        byte paddingOctet = (byte) (len & 0xff);
        for (int i = 0; i < len; i++) {
            in[i + off] = paddingOctet;
View Full Code Here

    {
        if (in == null)
            return;

        if ((off + len) > in.length) {
            throw new ShortBufferException("Buffer too small to hold padding");
        }

        byte paddingOctet = (byte) (len & 0xff);
        byte[] padding = new byte[len];
        SunJCE.RANDOM.nextBytes(padding);
View Full Code Here

        }
        int result = input.limit() - input.position();
        try {
            output.put(input);
        } catch (java.nio.BufferOverflowException e) {
            throw new ShortBufferException(Messages.getString("crypto.0F", e)); //$NON-NLS-1$
        }
        return result;
    }
View Full Code Here

    /**
     * Test for <code>ShortBufferException()</code> constructor Assertion:
     * constructs ShortBufferException with no detail message
     */
    public void testShortBufferException01() {
        ShortBufferException tE = new ShortBufferException();
        assertNull("getMessage() must return null.", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
View Full Code Here

TOP

Related Classes of javax.crypto.ShortBufferException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.