Updated on 2026-08-14

This commit is contained in:
Tangem 2020-04-15 15:33:38 +03:00
parent 9580b97747
commit 00cb3c37d2
5 changed files with 46 additions and 46 deletions

View file

@ -26,13 +26,13 @@ data class SigningMethodMask(val rawValue: Int) {
}
enum class SigningMethod(val code: Int) {
SIGN_HASH(0),
SIGN_RAW(1),
SIGN_HASH_VALIDATE_BY_ISSUER(2),
SIGN_RAW_VALIDATE_BY_ISSUER(3),
SIGN_HASH_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA(4),
SIGN_RAW_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA(5),
SIGN_POS(6)
SignHash(0),
SignRaw(1),
SignHashValidateByIssuer(2),
SignRawValidateByIssuer(3),
SignHashValidateByIssuerWriteIssuerData(4),
SignRawValidateByIssuerWriteIssuerData(5),
SignPos(6)
}
class SigningMethodMaskBuilder() {
@ -101,10 +101,10 @@ data class ProductMask(val rawValue: Int) {
}
enum class Product(val code: Int) {
NOTE(0x01),
TAG(0x02),
ID_CARD(0x04),
ID_ISSUER(0x08)
Note(0x01),
Tag(0x02),
IdCard(0x04),
IdIssuer(0x08)
}
class ProductMaskBuilder() {
@ -327,21 +327,21 @@ class Card(
val activationSeed: ByteArray?,
/**
* Returned only if [SigningMethod.SIGN_POS] enabling POS transactions is supported by card.
* Returned only if [SigningMethod.SignPos] enabling POS transactions is supported by card.
*/
val paymentFlowVersion: ByteArray?,
/**
* This value can be initialized by terminal and will be increased by COS on execution of every [SignCommand].
* For example, this field can store blockchain nonce for quick one-touch transaction on POS terminals.
* Returned only if [SigningMethod.SIGN_POS] enabling POS transactions is supported by card.
* Returned only if [SigningMethod.SignPos] enabling POS transactions is supported by card.
*/
val userCounter: Int?,
/**
* This value can be initialized by App (with PIN2 confirmation) and will be increased by COS
* with the execution of each [SignCommand]. For example, this field can store blockchain nonce
* for a quick one-touch transaction on POS terminals. Returned only if [SigningMethod.SIGN_POS].
* for a quick one-touch transaction on POS terminals. Returned only if [SigningMethod.SignPos].
*/
val userProtectedCounter: Int?,

View file

@ -20,7 +20,7 @@ internal class ScanTask : CardSessionRunnable<Card> {
if (card == null) {
callback(CompletionResult.Failure(SessionError.MissingPreflightRead()))
} else if (card.cardData?.productMask?.contains(Product.TAG) != false) {
} else if (card.cardData?.productMask?.contains(Product.Tag) != false) {
callback(CompletionResult.Success(card))
} else if (card.status != CardStatus.Loaded) {

View file

@ -83,7 +83,7 @@ class TlvDecoderTest {
@Test
fun `map SigningMethods single value returns correct value`() {
val signingMethods: SigningMethodMask = tlvMapper.decode(TlvTag.SigningMethod)
assertThat(signingMethods.contains(SigningMethod.SIGN_HASH))
assertThat(signingMethods.contains(SigningMethod.SignHash))
.isTrue()
}
@ -92,19 +92,19 @@ class TlvDecoderTest {
val localMapper = TlvDecoder(Tlv.deserialize("070195".hexToBytes())!!)
val signingMethods: SigningMethodMask = localMapper.decode(TlvTag.SigningMethod)
assertThat(signingMethods.contains(SigningMethod.SIGN_HASH))
assertThat(signingMethods.contains(SigningMethod.SignHash))
.isTrue()
assertThat(signingMethods.contains(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER))
assertThat(signingMethods.contains(SigningMethod.SignHashValidateByIssuer))
.isTrue()
assertThat(signingMethods.contains(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA))
assertThat(signingMethods.contains(SigningMethod.SignHashValidateByIssuerWriteIssuerData))
.isTrue()
assertThat(signingMethods.contains(SigningMethod.SIGN_RAW))
assertThat(signingMethods.contains(SigningMethod.SignRaw))
.isFalse()
assertThat(signingMethods.contains(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER))
assertThat(signingMethods.contains(SigningMethod.SignRawValidateByIssuer))
.isFalse()
assertThat(signingMethods.contains(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA))
assertThat(signingMethods.contains(SigningMethod.SignRawValidateByIssuerWriteIssuerData))
.isFalse()
assertThat(signingMethods.contains(SigningMethod.SIGN_POS))
assertThat(signingMethods.contains(SigningMethod.SignPos))
.isFalse()
}
@ -119,7 +119,7 @@ class TlvDecoderTest {
fun `map ProductMask with raw value 5 returns correct value`() {
val localMapper = TlvDecoder(listOf(Tlv(TlvTag.ProductMask, byteArrayOf(5))))
val productMask: ProductMask = localMapper.decode(TlvTag.ProductMask)
assertThat(productMask.contains(Product.NOTE) && productMask.contains(Product.ID_CARD))
assertThat(productMask.contains(Product.Note) && productMask.contains(Product.IdCard))
.isTrue()
}
@ -127,7 +127,7 @@ class TlvDecoderTest {
fun `map ProductMask with raw value 1 returns correct value`() {
val localMapper = TlvDecoder(listOf(Tlv(TlvTag.ProductMask, byteArrayOf(1))))
val productMask: ProductMask = localMapper.decode(TlvTag.ProductMask)
assertThat(productMask.contains(Product.NOTE))
assertThat(productMask.contains(Product.Note))
.isTrue()
}

View file

@ -13,25 +13,25 @@ fun CardConfig.Companion.create(application: Application): CardConfig {
val signingMethodMaskBuilder = SigningMethodMaskBuilder()
if (preferences.getBoolean("personalization_SigningMethod_0", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH)
signingMethodMaskBuilder.add(SigningMethod.SignHash)
}
if (preferences.getBoolean("personalization_SigningMethod_1", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW)
signingMethodMaskBuilder.add(SigningMethod.SignRaw)
}
if (preferences.getBoolean("personalization_SigningMethod_2", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER)
signingMethodMaskBuilder.add(SigningMethod.SignHashValidateByIssuer)
}
if (preferences.getBoolean("personalization_SigningMethod_3", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER)
signingMethodMaskBuilder.add(SigningMethod.SignRawValidateByIssuer)
}
if (preferences.getBoolean("personalization_SigningMethod_4", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA)
signingMethodMaskBuilder.add(SigningMethod.SignHashValidateByIssuerWriteIssuerData)
}
if (preferences.getBoolean("personalization_SigningMethod_5", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA)
signingMethodMaskBuilder.add(SigningMethod.SignRawValidateByIssuerWriteIssuerData)
}
if (preferences.getBoolean("personalization_SigningMethod_6", false)) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH)
signingMethodMaskBuilder.add(SigningMethod.SignHash)
}
val signingMethod = signingMethodMaskBuilder.build()
@ -40,9 +40,9 @@ fun CardConfig.Companion.create(application: Application): CardConfig {
val isIdCard = preferences.getBoolean("personalization_ProductMask_IsIDCard", false)
val productMaskBuilder = ProductMaskBuilder()
if (isNote) productMaskBuilder.add(Product.NOTE)
if (isTag) productMaskBuilder.add(Product.TAG)
if (isIdCard) productMaskBuilder.add(Product.ID_CARD)
if (isNote) productMaskBuilder.add(Product.Note)
if (isTag) productMaskBuilder.add(Product.Tag)
if (isIdCard) productMaskBuilder.add(Product.IdCard)
val productMask = productMaskBuilder.build()
var tokenSymbol: String? = null

View file

@ -12,25 +12,25 @@ class PersonalizationConfigToCardConfig : Converter<PersonalizationConfig, CardC
override fun convert(from: PersonalizationConfig): CardConfig {
val signingMethodMaskBuilder = SigningMethodMaskBuilder()
if (from.SigningMethod0) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH)
signingMethodMaskBuilder.add(SigningMethod.SignHash)
}
if (from.SigningMethod1) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW)
signingMethodMaskBuilder.add(SigningMethod.SignRaw)
}
if (from.SigningMethod2) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER)
signingMethodMaskBuilder.add(SigningMethod.SignHashValidateByIssuer)
}
if (from.SigningMethod3) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER)
signingMethodMaskBuilder.add(SigningMethod.SignRawValidateByIssuer)
}
if (from.SigningMethod4) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA)
signingMethodMaskBuilder.add(SigningMethod.SignHashValidateByIssuerWriteIssuerData)
}
if (from.SigningMethod5) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_RAW_VALIDATE_BY_ISSUER_WRITE_ISSUER_DATA)
signingMethodMaskBuilder.add(SigningMethod.SignRawValidateByIssuerWriteIssuerData)
}
if (from.SigningMethod6) {
signingMethodMaskBuilder.add(SigningMethod.SIGN_HASH)
signingMethodMaskBuilder.add(SigningMethod.SignHash)
}
val signingMethod = signingMethodMaskBuilder.build()
@ -40,10 +40,10 @@ class PersonalizationConfigToCardConfig : Converter<PersonalizationConfig, CardC
val isIdIssuer = from.cardData.product_id_issuer
val productMaskBuilder = ProductMaskBuilder()
if (isNote) productMaskBuilder.add(com.tangem.commands.Product.NOTE)
if (isTag) productMaskBuilder.add(com.tangem.commands.Product.TAG)
if (isIdCard) productMaskBuilder.add(com.tangem.commands.Product.ID_CARD)
if (isIdIssuer) productMaskBuilder.add(com.tangem.commands.Product.ID_ISSUER)
if (isNote) productMaskBuilder.add(com.tangem.commands.Product.Note)
if (isTag) productMaskBuilder.add(com.tangem.commands.Product.Tag)
if (isIdCard) productMaskBuilder.add(com.tangem.commands.Product.IdCard)
if (isIdIssuer) productMaskBuilder.add(com.tangem.commands.Product.IdIssuer)
val productMask = productMaskBuilder.build()
var tokenSymbol: String? = null