I have coding I almost always use with my Omnikey RFID CardMan 5321 smart cards. Problem is we received new cards today which are marked "HID iCLASS GL" which do not appear to be working well with our coding.
Without going through the whole source, our problem is arising when we are calling the following line, which basically tells us the length of the data:
lResult = SCardTransmit(hCard, 0, bytCommand, lLen, 0, byReadBuffer, iReturnlength)
We are returning only a length of 2, which the data is marked as "x69 x86". Even if I tell it to read all 255 chr's the rest are just marked as null.
Now I know our reader can read these cards since the OMNIKEY Diagnostic tool is showing us the following:
Status: Smart Card Inserted
FW: 5.10
Port: USB
Lib: 1.0
Smart Card Nme: iCLASS 32KS 8x2+16
ART: Valid
Protocol: ISO 15693 (Part 2)
PICCtoPCD: 26,48 kbps
PCDtoPICC: 26,48 kbps
Frequ: 13.56 MHz
As I explained before, everything is working fine in my coding except no data is being returned for my card besides "x69 x86", which is surely not correct.
If anyone has any experience reading from a HID iCLASS card, I would greatly appreciate some feedback on how to. Even if we have to license software, that is ok.
Thanks in advance!
in case you are trying to access physical access data, I would thoroughly check the crypto protocol between reader and host first and also meke sure you are using a reader with teh latest firmware (5.20 for the OMNIKEY 5321).
I would also introduce code to check the card system withour secure communication channel between host and reader application.
Further references:
http://www.hidglobal.com/documents/ok_contactless_developer_guide_an_en.pdf
The reason cause you get a 2 Byte array is cause your command runs on an error so the chip returns only SW1 and SW2 Flag
in your case it's meaning is
x69 --> Command not allowed (further qualification in SW2, see table 17)
x86 --> Command not allowed (no current EF)
So you might proof that your application file on the chip is correctly selected
further information #
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table17
Related
I want to capture image via SNAPI API from Symbol (currently Zebra) barcode scanner, model DS4208 (we're also using another but compatible models from Zebra).
Barcode capturing/recognition works pretty well, but looks like SnapiDLL.SNAPI_SnapShot(hScanner) call don't work correctly: no WM_XFERSTATUS message received at all.
Here is small & simplified code snippet:
// Set image format
short[] parms = new short[2] { (short)SnapiParamIds.ImageFileType, (short)SnapiImageTypes.Jpeg };
var retCode = SnapiDLL.SNAPI_SetParameters(parms, 2, _devHandles[0]);
Debug.WriteLine($"SNAPI_SetParameters retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
retCode = SnapiDLL.SNAPI_SnapShot(_devHandles[0]);
Debug.WriteLine($"SNAPI_SnapShot retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
retCode = SnapiDLL.SNAPI_PullTrigger(_devHandles[0]);
Debug.WriteLine($"SNAPI_PullTrigger retCode={retCode}");
Application.DoEvents();
Thread.Sleep(50);
Return codes always 0 (i.e. no error), but no WM_XFERSTATUS message received by my message handler.
P.S. C# application from Zebra's SDK which is using CoreScanner driver and OCX, is working fine and able to capture images and video. But I'd like to avoid CoreScanner driver installation for some reasons; for barcode scanning small and simple SNAPI.dll works pretty fine, and I expect to get it work for image capturing too - probably, I'm doing something wrong...
P.P.S. Guys, please DO NOT COMMENT if you have NO EXPERIENCE WORKING WITH SYMBOL BARCODE SCANNERS & SNAPI, and CAN NOT PROVIDE a working snippet!
After contacting Zebra tech support (they are successors of Symbol/Motorola barcode scanner business), I figured out that the imaging/video functionality is broken in SNAPI.dll for the x64 OSes (but most of the rest API calls are working properly). Unfortunately, SNAPI isn't supported by Zebra anymore, and I should use Zebra's CoreScanner API. The good news is: this API is working fine, as it supposed to be. Not a very good news: I should use additional installation package from Zebra.
I am developing a tool, that encrypts emails with S/MIME in bulk within Outlook 2013. It works so far, but when I am trying to encrypt a REALLY BIG email (in the test case it was about 60MB raw). I get a COMException stating unsufficient ressources.
I can go around this, by working direktly with EWS and MimeKit (which works like a charm! Thank you #jstedfast), but I'd like to find a way to work in Outlook, for network traffic considerations. I know these changes will be synched to Exchange eventually, but during the process itself, it is independent of bandwidth.
I am also looking at MapiEx, but if there is an easier solution, than having yet another dependency (and with MFC too), I'd be happy! Maybe there are some settings, I'd have to make before.
A bit of code. The Exception it caught somewhere else.
public void String SetEncryption(MailItem mailItem)
{
PropertyAccessor pa = null;
try
{
pa = mailItem.PropertyAccessor;
Int32 prop = (int)pa.GetProperty(_PR_SECURITY_FLAGS);
Int32 newprop = prop | 1;
pa.SetProperty(_PR_SECURITY_FLAGS, newprop);
}
finally
{
Marshal.FinalReleaseComObject(pa);
pa = null;
}
}
Edit: The Exception is not coming, when the encryption is set, but when the result is saved, after the encryption is set.
SetEncryption(mailItem);
mailItem.Save();
I solved it myself.
Since I had the problems in Outlook itself, I was trying MAPIEx to access the raw S/MIME Attachment in the email and de-/encrypt it using MimeKit/BouncyCastle.
The same problem occoured, but with a different error message, which lead me to the following site: ASN.1 value too large.
To sum it up: The Crypto API has two signatures. One which takes a byte array and one, which takes a stream. The first one has an arbitrary imposed (!!!) limit of 100 Million Bytes. Since the enveloped CMS has double base64 the ratio of this 100 MB is 9/16, which is round about 56 MB.
I assume, that Outlook uses the same API-Call and therefore has this limit.
I know it is not a fact, but the evidence strongly supports this theory. :)
Check if KB 2480994 is installed: http://support.microsoft.com/kb/2480994
Since Vista, Windows is shipped with WIA 2.0 (wiaaut.dll).
According to the following KB article and many of my findings on various forums, duplex scanning is no longer possible using WIA 2.0. Yet, the article mentions the use of native WIA 2.0, what would make duplex scanning possible.
(https://support.microsoft.com/en-us/kb/2709992)
According to the WIA 2.0 documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/ms630196(v=vs.85).aspx), duplex scanning is possible but using the new WIA_IPS_DOCUMENT_HANDLING_SELECT (3088) property.
My issues are:
I have no idea how to use native WIA, I suspect when using C# its just not possible.
I cant find a way to set the new WIA_IPS_DOCUMENT_HANDLING_SELECT property, as the property is not present in my wiaDevice properties. According to WiaDef.h, its property id is still 3088 and the only possible value is 0x400 (1024).
If anyone could help me (and I think many others) out on this, it would be much appreciated!
Greetings,
M.
After a few more hours of searching I found a clue in the following post.
https://stackoverflow.com/a/7580686/3641369
As I used a one-pass duplex scanner, both front and back sides where scanned at the same time. By setting the device properties (device properties, not item properties) Document_Handling_Select to 5 (Feeder + Duplex) and Pages to 1 and calling the transfer method 2 times, I finally got the font and back side of the scan.
Setting wiaDev.Properties["Document Handling Select"] = 5 specifies the use of the feeder and scanning duplex.
Setting wiaDev.Properties["Pages"] = 1 specifies that the scanner should keep 1 page in memory, this allowing to keep both front side and back side of the page in memory during 1 scan pass.
if (duplex)
{
wiaDev.Properties["Document Handling Select"].set_Value(5);
wiaDev.Properties["Pages"].set_Value(1);
}
Getting the Wia item and setting item properties such as color and dpi.
var item = wiaDev.Items[1];
item.Properties["6146"].set_Value((int)clr);
item.Properties["6147"].set_Value(dpi);
item.Properties["6148"].set_Value(dpi);
Then calling the transfer method twice returns two different images
var img = (ImageFile)wiaCommonDialog.ShowTransfer(item, FormatID.wiaFormatJPEG);
ImageFile imgduplex = null;
if(duplex)
imgduplex = (ImageFile)wiaCommonDialog.ShowTransfer(item, FormatID.wiaFormatJPEG);
Hope this helps someone!
I use WinSCard to list all readers, which gives me a list like this:
ASK RDR4x7 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 1
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 2
Which is great, but I have no clue which name belongs to which card reader.
Where do these names come from? How are they constructed?
What I've found up until now: in the registry, there is a HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key. Under this key, you can find the subkey which matches the card reader's "service" (which I found by querying the WMI registry). For example: the service for the SCM Microsystems Inc. SCR3320 USB Smart Card Reader readers is SCR3XX2K.
This subkey (SCR3XX2K) has another subkey Enum, which has multiple interesting values:
Count: DWORD, the number of readers connected
0, 1, 2: STRING, hardware Device ID
I guess these are the numbers appended to the 'friendly names', but I can't figure out how the name string is constructed. I need this to map hardware Device ID's (which I get through WMI) to their friendly name.
So, what's the pattern used to create a 'friendly name' for a smart card reader, and where do the values come from?
They are a concatination of these 3 attributes:
SCARD_ATTR_VENDOR_NAME
SCARD_ATTR_VENDOR_IFD_TYPE
SCARD_ATTR_DEVICE_UNIT
The TechNet article Smart Card Events documents this in the "Smart Card reader name" section.
SCARD_??? attributes are requested with the SCardGetAttrib function.
The SCARD_ATTR_DEVICE_SYSTEM_NAME attribute returns the friendly name as the ones you get while listing the readers.
The list of SmartCard readers exists in the registry under HKLM\SOFTWARE\Microsoft\Cryptography\Calais\Readers. Readers are added to this list by the INF file of the SCR driver, so during driver installation.
A link between device and reader can be found in the SmartCardReader class {50DD5230-BA8A-11D1-BF5D-0000F805F530} under HKLM\SYSTEM\CurrentControlSet\Control\Class\{50DD5230-BA8A-11D1-BF5D-0000F805F530}.
I need to check if the power of a display/monitor (is it ON or OFF ?).
I've tried with WMI, using the Win32_DesktopMonitor and check the "Availability", but the value returned is always 3 (powered on), even when the monitor is physically turned off.
Now, looking at a few threads here on StackOverflow, there's one direction I'd like to follow and it's the use of IMSVidDevice Interface, but I have no clue how to use it.
I have this link http://msdn.microsoft.com/en-us/library/windows/desktop/dd694527(v=vs.85).aspx to start.
It talks about using segment.h and segment.idl. There's also the mention of msvidctl.h.
I found an MS Video Control 1.0 Type Library which seems to be what I'm looking for (it has an IMSVidDevice interface defined) but I can't figure out how to use this library.
var devices = new MSVidCtlLib.MSVidOutputDevices();
Console.WriteLine("Found {0} devices", devices.Count);
foreach (MSVidCtlLib.IMSVidOutputDevice dev in devices)
{
Console.WriteLine("{0}: {1} - {2}", dev.Name, dev.Status, dev.Power);
}
But the devices.count is always zero. I have two monitors on my dev box.
What am I missing ?