Package org.bouncycastle.crypto

Examples of org.bouncycastle.crypto.AsymmetricBlockCipher


      @Override
      public void run() {
        String keyAlgorithm = VanillaConfiguration.ENCRYPT_KEY_ALGORITHM.getString();
        String keyPadding = VanillaConfiguration.ENCRYPT_KEY_PADDING.getString();

        AsymmetricBlockCipher cipher = SecurityHandler.getInstance().getAsymmetricCipher(keyAlgorithm, keyPadding);

        try {
          AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(message.getSecretArray());
          cipher.init(SecurityHandler.ENCRYPT_MODE, publicKey);

          byte[] encodedSecret = cipher.processBlock(sharedSecret, 0, 16);
          byte[] encodedToken = cipher.processBlock(message.getVerifyTokenArray(), 0, 4);

          String streamCipher = VanillaConfiguration.ENCRYPT_STREAM_ALGORITHM.getString();
          String streamWrapper = VanillaConfiguration.ENCRYPT_STREAM_WRAPPER.getString();

          BufferedBlockCipher toServerCipher = SecurityHandler.getInstance().getSymmetricCipher(streamCipher, streamWrapper);
View Full Code Here


    // some data where first entry is 0
    byte[] data = { 10, 122, 12, 127, 35, 58, 87, 56, -6, 73, 10, -13, -78, 4, -122, -61 };

    // encrypt data asymmetrically
    AsymmetricBlockCipher cipher = new RSAEngine();
    cipher = new PKCS1Encoding(cipher);
    cipher.init(true, keyPair.getPublic());
    byte[] rsaEncryptedData = cipher.processBlock(data, 0, data.length);

    Assert.assertFalse(Arrays.equals(data, rsaEncryptedData));

    // decrypt data asymmetrically
    cipher.init(false, keyPair.getPrivate());
    byte[] dataBack = cipher.processBlock(rsaEncryptedData, 0, rsaEncryptedData.length);

    assertTrue(Arrays.equals(data, dataBack));

    long stopTime = System.currentTimeMillis();
    long elapsedTime = stopTime - startTime;
View Full Code Here

   */
  public static byte[] encryptCEK(final RSAPublicKey pub, final SecretKey cek)
    throws RuntimeException {

    try {
      AsymmetricBlockCipher engine = new RSAEngine();

      // JCA identifier RSA/ECB/OAEPWithSHA-1AndMGF1Padding ?
      OAEPEncoding cipher = new OAEPEncoding(engine);

      BigInteger mod = pub.getModulus();
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.AsymmetricBlockCipher

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.