Comments (4)
We are actively working on the implementation of the absent functionality of 3.0.4/3.0.5 - ALG_EC_SVDP_DH_PLAIN is slightly different from ALG_EC_SVDP_DH, and we will need to check the implementation on a card, I think within a couple of days this algorithm will be supported in jCardSim.
from jcardsim.
I wrote a standalone version recently (tested) and imported that to the KeyAgreementImpl (untested):
Have a try.
public class KeyAgreementImpl extends KeyAgreement {
BasicAgreement engine;
SHA1Digest digestEngine;
byte algorithm;
ECPrivateKeyImpl privateKey;
public KeyAgreementImpl(byte algorithm) {
this.algorithm = algorithm;
switch(algorithm) {
case 1:
this.engine = new ECDHBasicAgreement();
this.digestEngine = new SHA1Digest();
break;
case 2:
this.engine = new ECDHCBasicAgreement();
this.digestEngine = new SHA1Digest();
break;
case 3:
this.engine = new ECDHBasicAgreement();
this.digestEngine = null;
break;
default:
CryptoException.throwIt((short)3);
}
}
public void init(PrivateKey privateKey) throws CryptoException {
if(privateKey == null) {
CryptoException.throwIt((short)2);
}
if(!(privateKey instanceof ECPrivateKeyImpl)) {
CryptoException.throwIt((short)1);
}
this.engine.init(((ECPrivateKeyImpl)privateKey).getParameters());
this.privateKey = (ECPrivateKeyImpl)privateKey;
}
public byte getAlgorithm() {
return this.algorithm;
}
public short generateSecret(byte[] publicData, short publicOffset, short publicLength, byte[] secret, short secretOffset) throws CryptoException {
byte[] publicKey = new byte[publicLength];
Util.arrayCopyNonAtomic(publicData, publicOffset, publicKey, (short)0, publicLength);
ECPublicKeyParameters ecp = new ECPublicKeyParameters(((ECPrivateKeyParameters)this.privateKey.getParameters()).getParameters().getCurve().decodePoint(publicKey), ((ECPrivateKeyParameters)this.privateKey.getParameters()).getParameters());
byte[] result = this.engine.calculateAgreement(ecp).toByteArray();
switch(algorithm) {
case 1:
case 2:
byte[] hashResult = new byte[20];
this.digestEngine.update(result, 0, result.length);
this.digestEngine.doFinal(hashResult, 0);
Util.arrayCopyNonAtomic(hashResult, (short)0, secret, secretOffset, (short)hashResult.length);
return (short)hashResult.length;
case 3:
Util.arrayCopyNonAtomic(result, (short)0, secret, secretOffset, (short)result.length);
return (short)result.length;
default:
CryptoException.throwIt((short)3);
}
}
}
from jcardsim.
J08nY opened pull request #121 implementing ALG_EC_SVDP_DH_PLAIN_XY
from jcardsim.
@licel DH_PLAIN
is now implemented along with DHC_PLAIN
and DH_PLAIN_XY
so this can be closed.
from jcardsim.
Related Issues (20)
- macOS build issues HOT 4
- miss object ASN1Primitive
- CAP files simulation & Security domain HOT 2
- AES-GCM (ALG_AES_GCM) is not supported. HOT 1
- Did not invoke my applet's install method
- Does not support store data command separated in 4 parts
- Trying to buy JCardSim?
- Issue while using it for PIV applet HOT 1
- jCardSim Maintenance
- Support of JCSystem.makeGlobalArray() call HOT 1
- java.lang.ClassNotFoundException: com.licel.globalplatform.GpSimulatorRuntime
- Lc = 0x00 is not allowed according to ISO7816-4 and should not work on any card or simulation. Your command is malformed. HOT 2
- Exception when trying to initialise CardSimulator class HOT 2
- Wrong Checksum.ALG_ISO3309_CRC32 implementation
- Exception when loading applet HOT 4
- Exception triggered when initialising the simulator along with JCDK
- Unexpected - Transient memory is bound to threadlocal, thus shared by two simulator instances
- Spordically wrong XY coordinates for secp256r1
- Can not start simulator HOT 2
- Implement KeyBuilder#buildKey(byte,byte,short,boolean) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jcardsim.