Beispiel #1
0
        protected override void EncodeParameters(Asn1Generator generator)
        {
            // Id
            var id = new DerApplicationSpecific(TAG_PARAM_ID, BinaryParser.ConvertInt16(Id, ByteEndianess.BigEndian));

            // Keyset - IA Modulus
            var iaModulus = new DerApplicationSpecific(TAG_KEYSET_IAMODULUS, new byte[PlaidApplication.LENGTH_KEY_RSA]);

            // Keyset - IA Exponent
            var iaExponent = new DerApplicationSpecific(TAG_KEYSET_IAEXPONENT, new byte[PlaidApplication.LENGTH_PUBLIC_EXPONENT]);

            // Keyset - FAKey
            var faKey = new DerApplicationSpecific(TAG_KEYSET_FAKEY, new byte[PlaidApplication.LENGTH_KEY_AES]);

            // Rules
            List <DerOctetString> rules = new List <DerOctetString>();

            foreach (var rule in Rules)
            {
                rules.Add(new DerOctetString(rule));
            }

            // Parameters (Choice)
            var parameters = new DerSequenceGenerator(generator.GetRawOutputStream(), OP_KEY_CREATE, false);

            parameters.AddObject(id);
            parameters.AddObject(new DerApplicationSpecific(TAG_PARAM_KEY, new Asn1EncodableVector(iaModulus, iaExponent, faKey)));
            parameters.AddObject(new DerApplicationSpecific(TAG_PARAM_RULES, new Asn1EncodableVector(rules.ToArray())));
            parameters.Close();

            // SamId
            var samId = new DerApplicationSpecific(TAG_SAMID, BinaryParser.ConvertInt16(SamId, ByteEndianess.BigEndian));

            generator.AddObject(samId);
        }
Beispiel #2
0
        protected override void EncodeParameters(Asn1Generator generator)
        {
            // Id
            generator.AddObject(new DerApplicationSpecific(TAG_PARAM_ID, BinaryParser.ConvertInt16(Id, ByteEndianess.BigEndian)));

            // Data
            generator.AddObject(new DerApplicationSpecific(TAG_PARAM_DATA, Data));
        }
Beispiel #3
0
        public PACSAMKey ReadNextKey(short index)
        {
            byte[] indexBytes = BinaryParser.ConvertInt16(index, ByteEndianess.BigEndian);

            // Transceive
            RApdu response = Transcieve(CLA, (byte)PACSAMCommand.ReadNextKey, indexBytes[0], indexBytes[1]);

            // Parse and test
            if (response.IsError)
            {
                // Check specifically for the SW_RECORD_NOT_FOUND status
                if (response.SW12 == 0x6A83)
                {
                    return(null);
                }

                // A legit error
                throw new Iso7816Exception(response.SW12, "ReadNextKey");
            }

            return(new PACSAMKey(response.Data));
        }