-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to inject Cipher and Signature implementations
this allows to replace certain Ciphers and Signatures with different implementations other than what comes with BouncyCastle or JCE. Sponsored by Lookout Inc.
Showing
4 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.jruby.ext.openssl; | ||
|
||
import javax.crypto.*; | ||
import java.security.*; | ||
import java.security.spec.AlgorithmParameterSpec; | ||
|
||
class CipherSpiFake extends CipherSpi { | ||
|
||
@Override | ||
protected void engineSetMode(String s) throws NoSuchAlgorithmException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineSetPadding(String s) throws NoSuchPaddingException { | ||
|
||
} | ||
|
||
@Override | ||
protected int engineGetBlockSize() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
protected int engineGetOutputSize(int i) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
protected byte[] engineGetIV() { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
protected AlgorithmParameters engineGetParameters() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected void engineInit(int i, Key key, SecureRandom secureRandom) throws InvalidKeyException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineInit(int i, Key key, AlgorithmParameterSpec algorithmParameterSpec, SecureRandom secureRandom) throws InvalidKeyException, InvalidAlgorithmParameterException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineInit(int i, Key key, AlgorithmParameters algorithmParameters, SecureRandom secureRandom) throws InvalidKeyException, InvalidAlgorithmParameterException { | ||
|
||
} | ||
|
||
@Override | ||
protected byte[] engineUpdate(byte[] bytes, int i, int i1) { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
protected int engineUpdate(byte[] bytes, int i, int i1, byte[] bytes1, int i2) throws ShortBufferException { | ||
return 0; | ||
} | ||
|
||
@Override | ||
protected byte[] engineDoFinal(byte[] bytes, int i, int i1) throws IllegalBlockSizeException, BadPaddingException { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
protected int engineDoFinal(byte[] bytes, int i, int i1, byte[] bytes1, int i2) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jruby.ext.openssl; | ||
|
||
import java.security.*; | ||
|
||
/** | ||
* Created by cmeier on 7/29/15. | ||
*/ | ||
class SignatureSpiFake extends Signature { | ||
|
||
SignatureSpiFake() { | ||
super("fake"); | ||
} | ||
|
||
@Override | ||
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineUpdate(byte b) throws SignatureException { | ||
|
||
} | ||
|
||
@Override | ||
protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { | ||
|
||
} | ||
|
||
@Override | ||
protected byte[] engineSign() throws SignatureException { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
protected boolean engineVerify(byte[] sigBytes) throws SignatureException { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void engineSetParameter(String param, Object value) throws InvalidParameterException { | ||
|
||
} | ||
|
||
@Override | ||
protected Object engineGetParameter(String param) throws InvalidParameterException { | ||
return null; | ||
} | ||
} |