Zugriff auf SmartCard Reader mit PCSC

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

lagraf
Posts: 450
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Zugriff auf SmartCard Reader mit PCSC

Post by lagraf »

Hallo Wolfgang,

Code: Select all

cryptoStream:Write(decrypted, 1, decrypted:Length)
hab ich schon probiert, hat aber nichts geändert. Aber ich habe soeben eine andere Array Schleife in der Methode TransformBlock gefunden, die mit 0 beginnt. Mit 1 beginnend geht die Routine schon mal nicht mehr in die Exception:

Code: Select all

PUBLIC METHOD TransformBlock(inputBuffer AS BYTE[] , inputOffset AS LONG , inputCount AS LONG , outputBuffer AS BYTE[] , outputOffset AS LONG ) AS LONG
	LOCAL i AS LONG
	LOCAL b AS BYTE
	//
	i := 0
	WHILE i < inputCount
		i++	// Index starts with 1 not 0!
		IF SELF:NeedMoreXorMaskBytes()
			SELF:EncryptCounterThenIncrement()
		ENDIF
		b := SELF:_xorMask:Dequeue()
		outputBuffer[outputOffset + i] := (BYTE)(inputBuffer[inputOffset + i] ^ b)
//		i++
	ENDDO
	RETURN inputCount
Wenn man in der FUNCTION Start() eine Ausgabe von encrypted hinzufügt

Code: Select all

EncryptAES256_CTR(@@array, OUT encrypted , Convert.FromBase64String(aeskey), kassa, renr)
? "encrypted.Length", encrypted.Length	// => Länge 8
FOREACH x AS BYTE IN encrypted
	? x   // => alle 8 Elemente sind 0
NEXT
sieht man dass encrypted zwar 8 Byte lang ist, aber alle Elemente sind 0 wodurch kein Crypto String rückgeliefert wird.
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Zugriff auf SmartCard Reader mit PCSC

Post by Chris »

Hi Franz ,

The problem is the translation of the the "^" operator of c# in the TransformBlock() method. This represents the xor operator in c#, but in X# this is used as the "Power of" operator (for compatibility with VO) so you need to change the code from

outputBuffer[outputOffset + i] := (BYTE)(inputBuffer[inputOffset + i] ^ b)

to

outputBuffer[outputOffset + i] := (BYTE)(_Xor(inputBuffer[inputOffset + i] , b))

and then it should work.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
lagraf
Posts: 450
Joined: Thu Jan 18, 2018 9:03 am
Location: A

Zugriff auf SmartCard Reader mit PCSC

Post by lagraf »

Hi Chris,
that's it, you're right, I would never have found that!
Thank you very much, now my X# DLL is complete, I extracted 10 classes and 70 methods from the original DLL.
Now I can go on with the next steps:
  • Test the X# DLL directly with an already from VO to X# transported app Passed
  • Make a com enabled DLL from it outstanding
  • Integrate the com enabled DLL into my VO apps and test it outstanding
And then I can discard the foreign DLL and use my own one.
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Zugriff auf SmartCard Reader mit PCSC

Post by Chris »

Hi Franz ,

You're welcome, glad it worked and good luck with the next steps! Myself I have very limited knowledge about COM stuff, but I'm sure the guys can further help you with that.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply