Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  storage.rs

  Sprache: Rust
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


use nsstring::nsACString;
use std::fs;
use std::io;

pub fn get_storage_path(storage_prefix: &nsACString) -> String {
    format!("{storage_prefix}.sqlite.enc")
}

pub fn get_key_path(storage_prefix: &nsACString) -> String {
    format!("{storage_prefix}.key")
}

fn read_existing_storage_key(key_path: &str) -> io::Result<[u8; 32]> {
    let key_hex = fs::read_to_string(key_path)?;
    let bytes = hex::decode(&key_hex).map_err(|e| io::Error::other(e))?;
    bytes[..].try_into().map_err(|e| io::Error::other(e))
}

pub fn get_storage_key(storage_prefix: &nsACString) -> io::Result<[u8; 32]> {
    // Get the key path
    let key_path = get_key_path(storage_prefix);

    // Try to read the existing key
    if let Ok(key) = read_existing_storage_key(&key_path) {
        return Ok(key);
    }

    // We failed to read the key, so it must either not exist, or is invalid.
    // Generate a new one.
    nss_gk_api::init();
    let key: [u8; 32] = nss_gk_api::p11::random(32)[..]
        .try_into()
        .expect("nss returned the wrong number of bytes");

    // Write the key to the file
    std::fs::write(key_path, &hex::encode(&key))?;

    // Return the key
    Ok(key)
}

Messung V0.5 in Prozent
C=96 H=100 G=97

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik