logo
down
shadow

error generating signed CSR with javacard (asn1 bad tag value)


error generating signed CSR with javacard (asn1 bad tag value)

By : Alejandro Gonzalez J
Date : November 20 2020, 11:01 PM
Hope this helps @Abraham analysis seems correct: the generated CSR content is not valid
I guess the purpose of this code is building the ASN.1 structure to sign, but bouncycastle do it for you.
code :
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(csrInfo);
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier("0.0");
v.add(new DERSequence(oid));
v.add(new DERBitString(new byte[] {}));
byte[] encoded = new DERSequence(v).getEncoded();
byte[] PKCS10= DataSignGeneration(encoded);
public byte[] generateCSR (X500Name subject, PublicKey publicKey, String signatureAlgorithm) throws Exception{
    //Create the unsigned CSR
    CertificationRequestInfo info = new CertificationRequestInfo(
                    x500name, SubjectPublicKeyInfo.getInstance(publicKey.getEncoded()),new DERSet());

    //The CSR bytes to be signed
    byte dataToSign[] = info.getEncoded(ASN1Encoding.DER);

    //Send the CSR to the card
    byte signedData[] = signOnJavaCard (dataToSign,signatureAlgorithm);

    //Build the signed CSR
    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find(signatureAlgorithm);
    PKCS10CertificationRequest csr = new PKCS10CertificationRequest(
                    new CertificationRequest(info, sigAlgId, new DERBitString(signedData)));
    byte signedCSR = csr.getEncoded();

    //Verify signature validity
    ContentVerifierProvider verifier = new JcaContentVerifierProviderBuilder().setProvider(new BouncyCastleProvider()).build(publicKey);
    boolean valid = csr.isSignatureValid(verifier);

    return signedCSR;
}
public byte signOnJavaCard (byte dataToSign[], String signatureAlgorithm)
    Signature signature = Signature.getInstance(signatureAlgorithm);
    signature.initSign(privateKey); //get the private key in some way...
    signature.update(dataToSign);
    return signature.sign();
}


Share : facebook icon twitter icon
Verifying a signed string in JavaCard return `0x6F00` status word

Verifying a signed string in JavaCard return `0x6F00` status word


By : Luca Giuseppe Caliò
Date : March 29 2020, 07:55 AM
wish helps you Your verify() arguments are probably swapped (given you have [128 bytes signature][4 bytes data] in the incomingData):
code :
boolean isVerified = signature.verify(incomingData, (short)0x80, (short) 4, incomingData, (short)0, (short)0x80);
Error while generating a signed APK

Error while generating a signed APK


By : Robert Casarotto
Date : March 29 2020, 07:55 AM
To fix the issue you can do So, everytime I try to generate a signed apk this error comes and it won't let me finish generating signed apk: , Try this in app gradle inside android{}
code :
lintOptions { 
    checkReleaseBuilds false
}
Export Time stamp 'signing_time' from signed data in asn1 format

Export Time stamp 'signing_time' from signed data in asn1 format


By : Roni Purwanto
Date : March 29 2020, 07:55 AM
this one helps. Question is: Exporting timestamp (signing time) from signeddata? I verify my signature before. I have an asn1 signed data to verification. ,
Question: My question is getting time stamp (signing time)
code :
import os
from asn1crypto import cms

"""
https://github.com/wbond/asn1crypto/blob/master/tests/fixtures/pkcs7-signed.der
"""
fixtures_dir = 'tests/fixtures'
with open(os.path.join(fixtures_dir, 'pkcs7-signed.der'), 'rb') as f:
    der_bytes = f.read()

info = cms.ContentInfo.load(der_bytes)
signed_data = info['content']

encap_content_info = signed_data['encap_content_info']
print("message:{}".format(encap_content_info['content'].native.decode()))
#>>> message:This is the message to encapsulate in PKCS#7/CMS

signer = signed_data['signer_infos'][0]

# signed_attrs == cms.CMSAttributes()
signed_attrs = signer['signed_attrs']
print("signing_time:{}".format(signed_attrs[1]['values'][0].native))
# signed_attrs.native == List of OrderedDict with keys 'type' and 'values'
for i, attr in enumerate(signed_attrs.native):
    print("[{}]:{}:\t{}".format(i, attr['type'], attr['values']))
[0]:content_type:   ['data']
[1]:signing_time:   [datetime.datetime(2015, 6, 3, 5, 55, 12, tzinfo=datetime.timezone.utc)]
[2]:message_digest: [b'R\x88%G\x15[-PDh\x05$\xc8qZ\xccb(6\x17\xb7h\xee\xa1\x12\x90\x96O\x94\xae\xdby']
[3]:1.2.840.113549.1.9.15:  [OrderedDict([('0', OrderedDict([('0', '2.16.840.1.101.3.4.1.42')])), ... (omitted for brevity)]
f = [attr['values'] for attr in signed_attrs.native if attr['type'] == 'signing_time'][0]
print(f)
>>> [datetime.datetime(2015, 6, 3, 5, 55, 12, tzinfo=datetime.timezone.utc)]
Error in generating C code from GSM-TCAP asn1 files

Error in generating C code from GSM-TCAP asn1 files


By : Cretu Ionut
Date : March 29 2020, 07:55 AM
I wish this help you You don't need to compile all asn files in asn sub-directory. There is a rebuild script that you could use.
code :
asn1c $ASN/DialoguePDUs.asn $ASN/tcap.asn $ASN/UnidialoguePDUs.asn 
Allow only signed applets to be installed on a JavaCard managed by GlobalPlatform 2.2.1

Allow only signed applets to be installed on a JavaCard managed by GlobalPlatform 2.2.1


By : Prashanth Kumar
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You should read the Global Platform Specification, all information is given there. Points to look out for that should match your requirements:
Mandated DAP Verification Delegated Management Tokens
Related Posts Related Posts :
  • Issue with multiscreen design
  • Upload binary file with retrofit 2 in Android
  • R.layout is'nt recogized by the studio
  • android - RecyclerView updating every second and have a longPressListener
  • What's the best way (in Android dev) to consume REST API (in addition to Retrofit)?
  • Which Android SDK Packages do I need for Cordova and Android 4+
  • Android & Retrofit2 - posting image file in multipart request
  • Calabash directory structure for testing both Android and iOS
  • javafxports 8.60.7 - using Back button on Android - none exit application
  • Create file from drawable to send with sendbird
  • Firebase app integration error
  • Xamarin No resource found that matches the given name (at 'colorAccent' with value '@color/accent ')
  • Will Firebase provide tests for other OS and does it support manual testing?
  • Android - Obtain self-signed server certificate and add to trusted keystore
  • Error:(25, 46) error: @InjectViews must be a List or array
  • What is the difference between 'Make' and 'Gradle-aware Make'?
  • How to know if user has verified his/her email address
  • Importing Android-Download-Manager library results "failed to resolve"?
  • Showing particular area in google PlacePicker
  • Sharing pdf to Evernote not working in Android
  • Android : Google signin is not working in release mode
  • How to save an intent object and later retrieve it
  • Convert YUV Image into greyscale Image - Same Result as RGB to Grayscale?
  • bulkTransfer makes the application crash
  • How to aspect fill programmatically? [Android]
  • I lost my key store password, I want to update my app on plays store with same keystore
  • How to find the minimum and maximum dates from three tables even if there is no date in one table in android sqlite
  • Unparseable date: "10:40:54" (at offset 0)
  • Keep count of consumable in-app purchases using Firebase Realtime Database
  • Proguard with Parceler and Realm
  • Check whether the file is already exists Android not working
  • Update value to mutiply objects by Transaction in Firebase
  • how to save another image in android?
  • android thread only runs once
  • working with custom views and sqlite database-android
  • Android 4.x - NavigationView ignores android:theme parameter
  • Travis CI with Android Lib - No compatible devices connected
  • A blank white screen appeared when addview to windowmanager
  • Error:Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType
  • How do I display an ImageView underneath the middle of a LinearLayout?
  • Why setVisibility only works setOnClickListener but not in onClick?
  • How can I get packets data from AudioStream Android?
  • How to import open source library as an external project into Android Studio?
  • Android Studio Gradle API compatibility
  • Travis CI Build failing on Android app Unsupported major.minor version 52
  • Android clearing notifications not detected
  • Android updating custom preference summary
  • How to clear a recyclerview on app start
  • selectableItemBackground with white background on tablayout?
  • cordova plugin rm cordova-plugin-whitelist does not change config.xml so it will be readded upon build
  • Html.fromHtml on Nougat doesn't call custom HtmlHandler
  • Android Very huge list of items with recyclerview best approach
  • Dagger2 Inject a lot of activities/fragments/services (possible get a lot of NPE)
  • images vs views(button, radiobutton....) in Android
  • Not able to stop service, stopService()-method doesn't work
  • Android sharing between apps using ContentUri
  • Write text with canvas (onDraw view)
  • Trouble with implementing app for different screens on Android
  • Android remove EditText selection
  • Batch job - violate constraint temporarily
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com