Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
AI & KI NachrichtenAI Restrictions at NYCPS and LAUSD Reverberate Nationwide(24.09.2026 um 01:16 Uhr)
AI & KI NachrichtenMeta Connect 2026: The biggest news and announcements(24.09.2026 um 00:45 Uhr)
AI & KI NachrichtenMeta ditches the camera on its newest smart glasses(24.09.2026 um 01:37 Uhr)
AI & KI NachrichtenMuse is coming to Meta smart glasses(24.09.2026 um 01:40 Uhr)
AI & KI NachrichtenAI Restrictions at NYCPS and LAUSD Reverberate Nationwide(24.09.2026 um 01:16 Uhr)
AI & KI NachrichtenMeta Connect 2026: The biggest news and announcements(24.09.2026 um 00:45 Uhr)
AI & KI NachrichtenMeta ditches the camera on its newest smart glasses(24.09.2026 um 01:37 Uhr)
AI & KI NachrichtenMuse is coming to Meta smart glasses(24.09.2026 um 01:40 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Session-Based Symmetric Key Generation with CryptoKit

Read the original article:Session-Based Symmetric Key Generation with CryptoKit Problem Description In secure applications, it is often necessary to generate a session-specific symmetric key that exists only for the duration of …

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

Read the original article:Session-Based Symmetric Key Generation with CryptoKit






Problem Description



In secure applications, it is often necessary to generate a session-specific symmetric key that exists only for the duration of a single communication or workflow.

This key must be created securely on-device and used for cryptographic operations such as message authentication or encryption, then discarded after the session.






Background Knowledge




  • CryptoKit (HarmonyOS ArkTS): Provides APIs for generating and managing cryptographic keys such as HMAC or 3DES keys.

  • Symmetric key: The same key is used for both encryption and decryption, or for signing and verification (HMAC).

  • Session key: A temporary symmetric key created for a single session, improving security by limiting key lifetime.






Troubleshooting Process



While implementing a session-based key:




  1. Verified that CryptoKit supports runtime generation of symmetric keys (generateSymKey method).

  2. Checked correct algorithm naming (HMAC for HMAC keys).

  3. Ensured ArkTS async/await syntax is used to avoid type errors and to properly await key generation.

  4. Confirmed that the generated key can be encoded and represented in hex for debugging.






Analysis Conclusion



CryptoKit’s createSymKeyGenerator with the generateSymKey method is sufficient to create a session-specific key entirely within a single .ets file, without external services or multiple modules.






Solution



Below is a single ArkTS .ets file example that:




  • Generates a 256-bit HMAC session key on demand,

  • Computes and verifies an HMAC value for a sample message,

  • Displays the key and verification results on the UI.




import { cryptoFramework } from '@kit.CryptoArchitectureKit';
import { BusinessError } from '@kit.BasicServicesKit';

@Entry
@Component
struct Index {
@State sessionKeyHex: string = '';
@State hmacResultHex: string = '';
@State hmacVerify: string = '';
@State isGenerating: boolean = false;
@State isComputing: boolean = false;

private currentSessionKey: cryptoFramework.SymKey | null = null;

private async generateSessionKey(): Promise<cryptoFramework.SymKey> {
return new Promise((resolve, reject) => {
try {
const keyData = new Uint8Array(32);
for (let i = 0; i < keyData.length; i++) {
keyData[i] = Math.floor(Math.random() * 256);
}

const keyBlob: cryptoFramework.DataBlob = { data: keyData };
const generator = cryptoFramework.createSymKeyGenerator('HMAC');

generator.convertKey(keyBlob)
.then((key: cryptoFramework.SymKey) => {
resolve(key);
})
.catch((err: BusinessError) => {
reject(new Error(`Key Generation Error: ${err.code} - ${err.message}`));
});
} catch (e) {
let err = e as BusinessError;
reject(new Error(`Key Generation Setup Error: ${err.code} - ${err.message}`));
}
});
}

private async handleGenerateKey(): Promise<void> {
this.isGenerating = true;
try {
this.currentSessionKey = await this.generateSessionKey();
const encoded = this.currentSessionKey.getEncoded();
this.sessionKeyHex = Array.from(encoded.data)
.map(b => b.toString(16).padStart(2, '0'))
.join('');

this.hmacResultHex = '';
this.hmacVerify = '';

console.log('Session key generated successfully');
} catch (error) {
console.error('Key generation failed:', error);
this.sessionKeyHex = `Error: ${error.message}`;
this.currentSessionKey = null;
} finally {
this.isGenerating = false;
}
}


build() {
Scroll() {
Column() {
Column() {
Button(this.isGenerating ? 'Generating...' : 'Generate Session Key')
.onClick(() => this.handleGenerateKey())
.enabled(!this.isGenerating)
.width('100%')
.height(48)
.backgroundColor(this.isGenerating ? '#cccccc' : '#007AFF')
if (this.sessionKeyHex.length > 0) {
if (this.sessionKeyHex.startsWith('Error:')) {
Text(this.sessionKeyHex)
.fontSize(14)
.fontColor(Color.Red)
.margin({ top: 8 })
.textAlign(TextAlign.Center)
} else {
Column({ space: 4 }) {
Text('Session Key (256-bit HMAC):')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#333333')
.padding(12)
Text(this.sessionKeyHex)
.fontSize(12)
.fontColor('#666666')
.backgroundColor('#f5f5f5')
.padding(12)
.borderRadius(8)
.wordBreak(WordBreak.BREAK_ALL)
.width('100%')
.textAlign(TextAlign.Start)
}
.alignItems(HorizontalAlign.Start)
.width('100%')
}
}
}
.padding(16)
.backgroundColor('#f8f9fa')
.borderRadius(12)
}
.width('100%')
.padding(20)
}
.width('100%')
.height('100%')
.backgroundColor('#ffffff')
}
}









Verification Result




  • Running this code on a HarmonyOS device generates a new 256-bit HMAC session key every time the button is pressed.

  • The computed HMAC is displayed in hex format and verification confirms correctness.










Written by Hatice Akyel

IR-PLAYBOOK-VULN-REMEDIATION
MEDIUM
SOC Incident Playbook: Vulnerability Remediation & Verification
1-Click Detection Engineering: Sigma & YARA Rules
SOC Ready
title: Detect Exploitation - Session-Based Symmetric Key Generation with CryptoKit
id: eeec45c6-af2b-42d1-8c8e-6c61d9d4fd5d
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
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
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Session-Based Symmetric Key Ge" ascii wide
    condition:
        any of them
}
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Session-Based Symmetric Key Generation with CryptoKit

Thematisch verwandte Begriffe: SessionBased, Symmetric, Generation, with · 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-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
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
🔖 Gespeicherte Artikel
📂 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...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick