Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
••••••
Sicherheitslücken (CVE)CVE-2026-53682 | Dogtag PKI REST API access control(25.09.2026 um 04:49 Uhr)
••••••••••
Sicherheitslücken (CVE)CVE-2026-53682 | Dogtag PKI REST API access control(25.09.2026 um 04:49 Uhr)
••••
Intelligence View
⚡ tsecurity.de Intelligence

Generate SM2 Key Pair Using Key Parameters for Encryption and Decryption

Read the original article:Generate SM2 Key Pair Using Key Parameters for Encryption and Decryption Question In SM2 encryption and decryption, HarmonyOS requires ASN.1 serialized key data (91-byte public key, 51-byte private k…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Read the original article:Generate SM2 Key Pair Using Key Parameters for Encryption and Decryption






Question



In SM2 encryption and decryption, HarmonyOS requires ASN.1 serialized key data (91-byte public key, 51-byte private key). However, most SM2 key data is provided as raw, unserialized data (64-byte public key, 32-byte private key), which cannot be used directly.



How can raw SM2 keys be converted into ASN.1 serialized SM2 key pairs that are usable on the HarmonyOS platform?






Short Answer



You need to reconstruct SM2 keys from the raw parameters by generating public and private keys using cryptoFramework with ASN.1 specification.




  • Generate the SM2 public key based on the key parameters, as follows:




  /**
* Generate SM2 public key based on public key parameters
* @param keyStr The general format of the public key parameter is 04 + x + y.
* @returns SM2 public key
*/

async function convertStrToPubKey(keyStr: string): Promise<cryptoFramework.PubKey> {
let pubKeyStr = keyStr.startsWith("04") ? keyStr.slice(2) : keyStr;
let pkPart1 = pubKeyStr.slice(0, pubKeyStr.length / 2);
let pkPart2 = pubKeyStr.slice(pubKeyStr.length / 2);
// Enter hexadecimal in the corresponding position
let pk: cryptoFramework.Point = {
x: BigInt("0x" + pkPart1),
y: BigInt("0x" + pkPart2),
}
// Public key object parameters
let pubKeySpec: cryptoFramework.ECCPubKeySpec = {
params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'),
pk: pk,
algName: "SM2",
specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC
}
let keypairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(pubKeySpec);
return await keypairGenerator.generatePubKey();
}







  • Generate the SM2 private key based on the key parameters as follows:




  /**
* Generate SM2 private key based on private key parameters
* @param keyStr The private key parameter is generally a 128-bit string.
* @returns SM2 private key
*/

async function convertStrToPriKey(keyStr: string): Promise<cryptoFramework.PriKey> {
let sk = BigInt("0x" + keyStr);
// Private key object parameters
let priKeySpec: cryptoFramework.ECCPriKeySpec = {
params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'),
sk: sk,
algName: "SM2",
specType: cryptoFramework.AsyKeySpecType.PRIVATE_KEY_SPEC
}
let keypairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(priKeySpec);
return await keypairGenerator.generatePriKey();
}






For details, refer to the document SM2 Encryption and Decryption.






Applicable Scenarios




  • When raw SM2 key data (64-byte public key, 32-byte private key) is provided.

  • When HarmonyOS requires ASN.1 serialized key data (91-byte public key, 51-byte private key) for SM2 encryption and decryption.





SM2 Encryption and Decryption - HarmonyOS Documentation



How do I encrypt and decrypt public and private keys?






Written by Bilal Basboz

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - Generate SM2 Key Pair Using Key Parameters for Encryption and Decryption
id: 8ab6aa96-0954-4937-a9ab-c91e484795b6
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Generate SM2 Key Pair Using Ke" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Generate SM2 Key Pair Using Key Paramete")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Generate SM2 Key Pair Using Key Paramete*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Generate SM2 Key Pair Using Key Paramete"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Generate SM2 Key Pair Using Key Paramete.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Generate SM2 Key Pair Using Key Parameters for Encryption and Decryption

Thematisch verwandte Begriffe: Generate, Pair, Using, Parameters · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-87722 | Uncontrolled Resource Consumption (CWE-400 / CWE-1333) in regex search q…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle