c_path stringclasses 26
values | c_func stringlengths 79 17.1k | rust_path stringlengths 34 53 | rust_func stringlengths 53 16.4k | rust_context stringlengths 0 36.3k | rust_imports stringlengths 0 2.09k | rustrepotrans_file stringlengths 56 77 |
|---|---|---|---|---|---|---|
projects/deltachat-core/c/dc_chat.c | * be unexpected as (1) deleting a normal chat also does not prevent new mails
* from arriving, (2) leaving a group requires sending a message to
* all group members - especially for groups not used for a longer time, this is
* really unexpected when deletion results in contacting all members again,
* (3) ... | projects/deltachat-core/rust/chat.rs | pub async fn delete(self, context: &Context) -> Result<()> {
ensure!(
!self.is_special(),
"bad chat_id, can not be a special chat: {}",
self
);
let chat = Chat::load_from_db(context, self).await?;
context
.sql
.execute(
... | pub(crate) async fn set_config_internal(&self, key: Config, value: Option<&str>) -> Result<()> {
self.set_config_ex(Sync, key, value).await
}
pub fn new(viewtype: Viewtype) -> Self {
Message {
viewtype,
..Default::default()
}
}
pub(crate) fn emit_chatlist_change... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__30.txt |
projects/deltachat-core/c/dc_sqlite3.c | void dc_sqlite3_close(dc_sqlite3_t* sql)
{
if (sql==NULL) {
return;
}
if (sql->cobj)
{
sqlite3_close(sql->cobj);
sql->cobj = NULL;
}
} | projects/deltachat-core/rust/sql.rs | async fn close(&self) {
let _ = self.pool.write().await.take();
// drop closes the connection
} | pub struct Sql {
/// Database file path
pub(crate) dbfile: PathBuf,
/// Write transactions mutex.
///
/// See [`Self::write_lock`].
write_mtx: Mutex<()>,
/// SQL connection pool.
pool: RwLock<Option<Pool>>,
/// None if the database is not open, true if it is open with passphrase a... | use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use anyhow::{bail, Context as _, Result};
use rusqlite::{config::DbConfig, types::ValueRef, Connection, OpenFlags, Row};
use tokio::sync::{Mutex, MutexGuard, RwLock};
use crate::blob::BlobObject;
use crate::chat::{self, add_device_msg, update_dev... | projects__deltachat-core__rust__sql__.rs__function__6.txt |
projects/deltachat-core/c/dc_msg.c | char* dc_msg_get_filemime(const dc_msg_t* msg)
{
char* ret = NULL;
char* file = NULL;
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
goto cleanup;
}
ret = dc_param_get(msg->param, DC_PARAM_MIMETYPE, NULL);
if (ret==NULL) {
file = dc_param_get(msg->param, DC_PARAM_FILE, NULL);
if (file==NULL) {
goto clean... | projects/deltachat-core/rust/message.rs | pub fn get_filemime(&self) -> Option<String> {
if let Some(m) = self.param.get(Param::MimeType) {
return Some(m.to_string());
} else if let Some(file) = self.param.get(Param::File) {
if let Some((_, mime)) = guess_msgtype_from_suffix(Path::new(file)) {
return Some... | pub fn get(&self, contact_id: ContactId) -> Reaction {
self.reactions.get(&contact_id).cloned().unwrap_or_default()
}
pub(crate) fn guess_msgtype_from_suffix(path: &Path) -> Option<(Viewtype, &str)> {
let extension: &str = &path.extension()?.to_str()?.to_lowercase();
let info = match extension {
... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__22.txt |
projects/deltachat-core/c/dc_chat.c | void dc_lookup_real_nchat_by_contact_id(dc_context_t* context, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked)
{
/* checks for "real" chats or self-chat */
sqlite3_stmt* stmt = NULL;
if (ret_chat_id) { *ret_chat_id = 0; }
if (ret_chat_blocked) { *ret_chat_blocked = 0; }
if (context==... | projects/deltachat-core/rust/chat.rs | pub async fn lookup_by_contact(
context: &Context,
contact_id: ContactId,
) -> Result<Option<Self>> {
ensure!(context.sql.is_open().await, "Database not available");
ensure!(
contact_id != ContactId::UNDEFINED,
"Invalid contact id requested"
);
... | pub async fn is_open(&self) -> bool {
self.pool.read().await.is_some()
}
pub async fn query_row_optional<T, F>(
&self,
sql: &str,
params: impl rusqlite::Params + Send,
f: F,
) -> Result<Option<T>>
where
F: Send + FnOnce(&rusqlite::Row) -> rusqlite::Result<T>,... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__98.txt |
projects/deltachat-core/c/dc_context.c | * Searching can be done globally (chat_id=0) or in a specified chat only (chat_id
* set).
*
* Global chat results are typically displayed using dc_msg_get_summary(), chat
* search results may just hilite the corresponding messages and present a
* prev/next button.
*
* @memberof dc_context_t
* @param context The... | projects/deltachat-core/rust/context.rs | pub async fn search_msgs(&self, chat_id: Option<ChatId>, query: &str) -> Result<Vec<MsgId>> {
let real_query = query.trim();
if real_query.is_empty() {
return Ok(Vec::new());
}
let str_like_in_text = format!("%{real_query}%");
let list = if let Some(chat_id) = chat_i... | pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
pub async fn query_map<T, F, G, H>(
&self,
sql: &str,
params: impl rusqlite::Params + Send,
f: F,
mut g: G,
) -> Result<H>
where
F: Send + FnMut(&rusqlite::Row) -> rusqlite::Result<T>,
G... | use std::collections::{BTreeMap, HashMap};
use std::ffi::OsString;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
us... | projects__deltachat-core__rust__context__.rs__function__47.txt |
projects/deltachat-core/c/dc_param.c | int32_t dc_param_get_int(const dc_param_t* param, int key, int32_t def)
{
if (param==NULL || key==0) {
return def;
}
char* str = dc_param_get(param, key, NULL);
if (str==NULL) {
return def;
}
int32_t ret = atol(str);
free(str);
return ret;
} | projects/deltachat-core/rust/param.rs | pub fn get_i64(&self, key: Param) -> Option<i64> {
self.get(key).and_then(|s| s.parse().ok())
} | pub fn get(&self, key: Param) -> Option<&str> {
self.inner.get(&key).map(|s| s.as_str())
}
pub struct Params {
inner: BTreeMap<Param, String>,
} | use std::collections::BTreeMap;
use std::fmt;
use std::path::PathBuf;
use std::str;
use anyhow::{bail, Error, Result};
use num_traits::FromPrimitive;
use serde::{Deserialize, Serialize};
use crate::blob::BlobObject;
use crate::context::Context;
use crate::mimeparser::SystemMessage;
use std::path::Path;
use std::str::Fr... | projects__deltachat-core__rust__param__.rs__function__12.txt |
projects/deltachat-core/c/dc_apeerstate.c | * Typically either DC_NOT_VERIFIED (0) if there is no need for the key being verified
* or DC_BIDIRECT_VERIFIED (2) for bidirectional verification requirement.
* @return public_key or gossip_key, NULL if nothing is available.
* the returned pointer MUST NOT be unref()'d.
*/
dc_key_t* dc_apeerstate_peek_... | projects/deltachat-core/rust/peerstate.rs | pub fn peek_key(&self, verified: bool) -> Option<&SignedPublicKey> {
if verified {
self.verified_key.as_ref()
} else {
self.public_key.as_ref().or(self.gossip_key.as_ref())
}
} | pub struct Peerstate {
/// E-mail address of the contact.
pub addr: String,
/// Timestamp of the latest peerstate update.
///
/// Updated when a message is received from a contact,
/// either with or without `Autocrypt` header.
pub last_seen: i64,
/// Timestamp of the latest `Autocrypt... | use std::mem;
use anyhow::{Context as _, Error, Result};
use deltachat_contact_tools::{addr_cmp, ContactAddress};
use num_traits::FromPrimitive;
use crate::aheader::{Aheader, EncryptPreference};
use crate::chat::{self, Chat};
use crate::chatlist::Chatlist;
use crate::config::Config;
use crate::constants::Chattype;
use ... | projects__deltachat-core__rust__peerstate__.rs__function__14.txt |
projects/deltachat-core/c/dc_configure.c | int dc_alloc_ongoing(dc_context_t* context)
{
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return 0;
}
if (dc_has_ongoing(context)) {
dc_log_warning(context, 0, "There is already another ongoing process running.");
return 0;
}
context->ongoing_running = 1;
context->shall_stop_ongoing = 0;
... | projects/deltachat-core/rust/context.rs | pub(crate) async fn alloc_ongoing(&self) -> Result<Receiver<()>> {
let mut s = self.running_state.write().await;
ensure!(
matches!(*s, RunningState::Stopped),
"There is already another ongoing process running."
);
let (sender, receiver) = channel::bounded(1);
... | pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct InnerContext {
/// Blob directory path
pub(crate) blobdir: PathBuf,
pub(crate) sql: Sql,
pub(crate) smeared_timestamp: SmearedTimestamp,
/// The global "ongoing" process state.
///
/// This is a global mutex-like sta... | use std::collections::{BTreeMap, HashMap};
use std::ffi::OsString;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
us... | projects__deltachat-core__rust__context__.rs__function__37.txt |
projects/deltachat-core/c/dc_tools.c | char* dc_get_abs_path(dc_context_t* context, const char* pathNfilename)
{
int success = 0;
char* pathNfilename_abs = NULL;
if (context==NULL || pathNfilename==NULL) {
goto cleanup;
}
pathNfilename_abs = dc_strdup(pathNfilename);
if (strncmp(pathNfilename_abs, "$BLOBDIR", 8)==0) {
if (context->b... | projects/deltachat-core/rust/blob.rs | pub fn to_abs_path(&self) -> PathBuf {
let fname = Path::new(&self.name).strip_prefix("$BLOBDIR/").unwrap();
self.blobdir.join(fname)
} | pub struct BlobObject<'a> {
blobdir: &'a Path,
name: String,
} | use core::cmp::max;
use std::ffi::OsStr;
use std::fmt;
use std::io::Cursor;
use dIterator;
use std::mem;
use std::path::{Path, PathBuf};
use anyhow::{format_err, Context as _, Result};
use base64::Engine as _;
use futures::StreamExt;
use image::codecs::jpeg::JpegEncoder;
use image::{DynamicImage, GenericImage, GenericI... | projects__deltachat-core__rust__blob__.rs__function__7.txt |
projects/deltachat-core/c/dc_tools.c | void dc_truncate_str(char* buf, int approx_chars)
{
if (approx_chars > 0 && strlen(buf) > approx_chars+strlen(DC_EDITORIAL_ELLIPSE))
{
char* p = &buf[approx_chars + 1]; /* null-terminate string at the desired length */
*p = 0;
if (strchr(buf, ' ')!=NULL) {
while (p[-1]!=' ' && p[-1]!='\n') { /* rewind to th... | projects/deltachat-core/rust/tools.rs | pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<str> {
let count = buf.chars().count();
if count > approx_chars + DC_ELLIPSIS.len() {
let end_pos = buf
.char_indices()
.nth(approx_chars)
.map(|(n, _)| n)
.unwrap_or_default();
if let ... | pub(crate) const DC_ELLIPSIS: &str = "[...]"; | use std::borrow::Cow;
use std::io::{Cursor, Write};
use std::mem;
use std::path::{Path, PathBuf};
use std::str::from_utf8;
use std::time::Duration;
use std::time::SystemTime as Time;
use std::time::SystemTime;
use anyhow::{bail, Context as _, Result};
use base64::Engine as _;
use chrono::{Local, NaiveDateTime, NaiveTim... | projects__deltachat-core__rust__tools__.rs__function__1.txt |
projects/deltachat-core/c/dc_msg.c | int dc_msg_is_starred(const dc_msg_t* msg)
{
return msg->id <= DC_MSG_ID_LAST_SPECIAL? 1 : 0;
} | projects/deltachat-core/rust/message.rs | pub fn is_special(self) -> bool {
self.0 <= DC_MSG_ID_LAST_SPECIAL
} | pub struct MsgId(u32); | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__3.txt |
projects/deltachat-core/c/dc_msg.c | * this using dc_msg_get_width() / dc_msg_get_height().
*
* See also dc_msg_get_duration().
*
* @memberof dc_msg_t
* @param msg The message object.
* @return Width in pixels, if applicable. 0 otherwise or if unknown.
*/
int dc_msg_get_width(const dc_msg_t* msg)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
re... | projects/deltachat-core/rust/message.rs | pub fn get_width(&self) -> i32 {
self.param.get_int(Param::Width).unwrap_or_default()
} | pub fn get_int(&self, key: Param) -> Option<i32> {
self.get(key).and_then(|s| s.parse().ok())
}
pub struct Message {
/// Message ID.
pub(crate) id: MsgId,
/// `From:` contact ID.
pub(crate) from_id: ContactId,
/// ID of the first contact in the `To:` header.
pub(crate) to_id: Cont... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__43.txt |
projects/deltachat-core/c/dc_contact.c | * Same as dc_contact_is_verified() but allows speeding up things
* by adding the peerstate belonging to the contact.
* If you do not have the peerstate available, it is loaded automatically.
*
* @private @memberof dc_context_t
*/
int dc_contact_is_verified_ex(dc_contact_t* contact, const dc_apeerstate_t* peerstate... | projects/deltachat-core/rust/contact.rs | pub async fn is_verified(&self, context: &Context) -> Result<bool> {
// We're always sort of secured-verified as we could verify the key on this device any time with the key
// on this device
if self.id == ContactId::SELF {
return Ok(true);
}
let Some(peerstate) = Pe... | pub(crate) async fn is_backward_verified(&self, context: &Context) -> Result<bool> {
let Some(backward_verified_key_id) = self.backward_verified_key_id else {
return Ok(false);
};
let self_key_id = context.get_config_i64(Config::KeyId).await?;
let backward_verified = backwa... | use std::cmp::{min, Reverse};
use std::collections::BinaryHeap;
use std::fmt;
use std::path::{Path, PathBuf};
use std::time::UNIX_EPOCH;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
use base64::Engine as _;
use deltachat_contact_tools::may_be_valid_addr;
use ... | projects__deltachat-core__rust__contact__.rs__function__46.txt |
projects/deltachat-core/c/dc_apeerstate.c | void dc_apeerstate_degrade_encryption(dc_apeerstate_t* peerstate, time_t message_time)
{
if (peerstate==NULL) {
return 0;
}
peerstate->prefer_encrypt = DC_PE_RESET;
peerstate->last_seen = message_time; /*last_seen_autocrypt is not updated as there was not Autocrypt:-header seen*/
} | projects/deltachat-core/rust/peerstate.rs | pub fn degrade_encryption(&mut self, message_time: i64) {
self.prefer_encrypt = EncryptPreference::Reset;
self.last_seen = message_time;
} | pub struct Peerstate {
/// E-mail address of the contact.
pub addr: String,
/// Timestamp of the latest peerstate update.
///
/// Updated when a message is received from a contact,
/// either with or without `Autocrypt` header.
pub last_seen: i64,
/// Timestamp of the latest `Autocrypt... | use std::mem;
use anyhow::{Context as _, Error, Result};
use deltachat_contact_tools::{addr_cmp, ContactAddress};
use num_traits::FromPrimitive;
use crate::aheader::{Aheader, EncryptPreference};
use crate::chat::{self, Chat};
use crate::chatlist::Chatlist;
use crate::config::Config;
use crate::constants::Chattype;
use ... | projects__deltachat-core__rust__peerstate__.rs__function__9.txt |
projects/deltachat-core/c/dc_imex.c | void dc_imex(dc_context_t* context, int what, const char* param1, const char* param2)
{
dc_param_t* param = dc_param_new();
dc_param_set_int(param, DC_PARAM_CMD, what);
dc_param_set (param, DC_PARAM_CMD_ARG, param1);
dc_param_set (param, DC_PARAM_CMD_ARG2, param2);
dc_job_kill_action(context, DC_JOB_... | projects/deltachat-core/rust/imex.rs | pub async fn imex(
context: &Context,
what: ImexMode,
path: &Path,
passphrase: Option<String>,
) -> Result<()> {
let cancel = context.alloc_ongoing().await?;
let res = {
let _guard = context.scheduler.pause(context.clone()).await?;
imex_inner(context, what, path, passphrase)
... | pub(crate) async fn free_ongoing(&self) {
let mut s = self.running_state.write().await;
if let RunningState::ShallStop { request } = *s {
info!(self, "Ongoing stopped in {:?}", time_elapsed(&request));
}
*s = RunningState::Stopped;
}
async fn imex_inner(
context: &Co... | use std::any::Any;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use ::pgp::types::KeyTrait;
use anyhow::{bail, ensure, format_err, Context as _, Result};
use deltachat_contact_tools::EmailAddress;
use futures::StreamExt;
use futures_lite::FutureExt;
use rand::{thread_rng, Rng};
use tokio::fs::{self, File};
use ... | projects__deltachat-core__rust__imex__.rs__function__1.txt |
projects/deltachat-core/c/dc_securejoin.c | char* dc_get_securejoin_qr(dc_context_t* context, uint32_t group_chat_id)
{
/* =========================================================
==== Alice - the inviter side ====
==== Step 1 in "Setup verified contact" protocol ====
======================================================... | projects/deltachat-core/rust/securejoin.rs | pub async fn get_securejoin_qr(context: &Context, group: Option<ChatId>) -> Result<String> {
/*=======================================================
==== Alice - the inviter side ====
==== Step 1 in "Setup verified contact" protocol ====
=====================================... | pub async fn ensure_secret_key_exists(context: &Context) -> Result<()> {
load_self_public_key(context).await?;
Ok(())
}
pub async fn lookup(
context: &Context,
namespace: Namespace,
chat: Option<ChatId>,
) -> Result<Option<String>> {
let token = match chat {
Some(chat_id) => {
... | use anyhow::{bail, Context as _, Error, Result};
use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
use crate::aheader::EncryptPreference;
use crate::chat::{self, Chat, ChatId, ChatIdBlocked, ProtectionStatus};
use crate::chatlist_events;
use crate::config::Config;
use crate::constants::Blocked;
u... | projects__deltachat-core__rust__securejoin__.rs__function__2.txt |
projects/deltachat-core/c/dc_contact.c | char* dc_addr_normalize(const char* addr)
{
char* addr_normalized = dc_strdup(addr);
dc_trim(addr_normalized);
if (strncmp(addr_normalized, "mailto:", 7)==0) {
char* old = addr_normalized;
addr_normalized = dc_strdup(&old[7]);
free(old);
dc_trim(addr_normalized);
}
return addr_normalized;
} | projects/deltachat-core/rust/oauth2.rs | fn normalize_addr(addr: &str) -> &str {
let normalized = addr.trim();
normalized.trim_start_matches("mailto:")
} | use std::collections::HashMap;
use anyhow::Result;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use serde::Deserialize;
use crate::config::Config;
use crate::context::Context;
use crate::provider;
use crate::provider::Oauth2Authorizer;
use crate::socks::Socks5Config;
use crate::tools::time;
use super:... | projects__deltachat-core__rust__oauth2__.rs__function__8.txt | |
projects/deltachat-core/c/dc_contact.c | int dc_addr_equals_self(dc_context_t* context, const char* addr)
{
int ret = 0;
char* normalized_addr = NULL;
char* self_addr = NULL;
if (context==NULL || addr==NULL) {
goto cleanup;
}
normalized_addr = dc_addr_normalize(addr);
if (NULL==(self_addr=dc_sqlite3_get_config(context->sql, "co... | projects/deltachat-core/rust/config.rs | pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
Ok(self
.get_config(Config::ConfiguredAddr)
.await?
.iter()
.any(|a| addr_cmp(addr, a))
|| self
.get_secondary_self_addrs()
.await?
.i... | pub(crate) async fn get_secondary_self_addrs(&self) -> Result<Vec<String>> {
let secondary_addrs = self
.get_config(Config::SecondaryAddrs)
.await?
.unwrap_or_default();
Ok(secondary_addrs
.split_ascii_whitespace()
.map(|s| s.to_string())
... | use std::env;
use std::path::Path;
use std::str::FromStr;
use anyhow::{ensure, Context as _, Result};
use base64::Engine as _;
use deltachat_contact_tools::addr_cmp;
use serde::{Deserialize, Serialize};
use strum::{EnumProperty, IntoEnumIterator};
use strum_macros::{AsRefStr, Display, EnumIter, EnumString};
use tokio::... | projects__deltachat-core__rust__config__.rs__function__27.txt |
projects/deltachat-core/c/dc_pgp.c | int dc_pgp_create_keypair(dc_context_t* context, const char* addr, dc_key_t* ret_public_key, dc_key_t* ret_private_key)
{
int success = 0;
pgp_key_t seckey;
pgp_key_t pubkey;
pgp_key_t subkey;
uint8_t subkeyid[PGP_KEY_ID_SIZE];
uint8_t* user_id = NULL;
pgp_memor... | projects/deltachat-core/rust/pgp.rs | pub(crate) fn create_keypair(addr: EmailAddress, keygen_type: KeyGenType) -> Result<KeyPair> {
let (signing_key_type, encryption_key_type) = match keygen_type {
KeyGenType::Rsa2048 => (PgpKeyType::Rsa(2048), PgpKeyType::Rsa(2048)),
KeyGenType::Rsa4096 => (PgpKeyType::Rsa(4096), PgpKeyType::Rsa(4096)... | pub struct KeyPair {
/// Email address.
pub addr: EmailAddress,
/// Public key.
pub public: SignedPublicKey,
/// Secret key.
pub secret: SignedSecretKey,
}
pub enum KeyGenType {
#[default]
Default = 0,
/// 2048-bit RSA.
Rsa2048 = 1,
/// [Ed25519](https://ed25519.cr.yp.to... | use std::collections::{BTreeMap, HashSet};
use std::io;
use std::io::Cursor;
use anyhow::{bail, Context as _, Result};
use deltachat_contact_tools::EmailAddress;
use pgp::armor::BlockType;
use pgp::composed::{
Deserializable, KeyType as PgpKeyType, Message, SecretKeyParamsBuilder, SignedPublicKey,
SignedPublicS... | projects__deltachat-core__rust__pgp__.rs__function__8.txt |
projects/deltachat-core/c/dc_chat.c | * The result must be dc_array_unref()'d
*
* The list is already sorted and starts with the oldest message.
* Clients should not try to re-sort the list as this would be an expensive action
* and would result in inconsistencies between clients.
*
* @memberof dc_context_t
* @param context The context object as ret... | projects/deltachat-core/rust/chat.rs | pub async fn get_chat_media(
context: &Context,
chat_id: Option<ChatId>,
msg_type: Viewtype,
msg_type2: Viewtype,
msg_type3: Viewtype,
) -> Result<Vec<MsgId>> {
// TODO This query could/should be converted to `AND type IN (?, ?, ?)`.
let list = context
.sql
.query_map(
... | pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct InnerContext {
/// Blob directory path
pub(crate) blobdir: PathBuf,
pub(crate) sql: Sql,
pub(crate) smeared_timestamp: SmearedTimestamp,
/// The global "ongoing" process state.
///
/// This is a global mutex-like sta... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__116.txt |
projects/deltachat-core/c/dc_msg.c | uint32_t dc_msg_get_from_id(const dc_msg_t* msg)
{
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) {
return 0;
}
return msg->from_id;
} | projects/deltachat-core/rust/message.rs | pub fn get_from_id(&self) -> ContactId {
self.from_id
} | pub struct ContactId(u32);
pub struct Message {
/// Message ID.
pub(crate) id: MsgId,
/// `From:` contact ID.
pub(crate) from_id: ContactId,
/// ID of the first contact in the `To:` header.
pub(crate) to_id: ContactId,
/// ID of the chat message belongs to.
pub(crate) chat_id: ChatId... | use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
use anyhow::{ensure, format_err, Context as _, Result};
use deltachat_contact_tools::{parse_vcard, VcardContact};
use deltachat_derive::{FromSql, ToSql};
use serde::{Deserialize, Serialize};
use tokio::{fs, io};
use crate::blob::BlobObject;
use crate::chat... | projects__deltachat-core__rust__message__.rs__function__32.txt |
projects/deltachat-core/c/dc_contact.c | uint32_t dc_contact_get_id(const dc_contact_t* contact)
{
if (contact==NULL || contact->magic!=DC_CONTACT_MAGIC) {
return 0;
}
return contact->id;
} | projects/deltachat-core/rust/contact.rs | pub fn get_id(&self) -> ContactId {
self.id
} | pub struct ContactId(u32);
pub struct Contact {
/// The contact ID.
pub id: ContactId,
/// Contact name. It is recommended to use `Contact::get_name`,
/// `Contact::get_display_name` or `Contact::get_name_n_addr` to access this field.
/// May be empty, initially set to `authname`.
name: String... | use std::cmp::{min, Reverse};
use std::collections::BinaryHeap;
use std::fmt;
use std::path::{Path, PathBuf};
use std::time::UNIX_EPOCH;
use anyhow::{bail, ensure, Context as _, Result};
use async_channel::{self as channel, Receiver, Sender};
use base64::Engine as _;
use deltachat_contact_tools::may_be_valid_addr;
use ... | projects__deltachat-core__rust__contact__.rs__function__36.txt |
projects/deltachat-core/c/dc_chat.c | uint32_t dc_get_chat_id_by_contact_id(dc_context_t* context, uint32_t contact_id)
{
uint32_t chat_id = 0;
int chat_id_blocked = 0;
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) {
return 0;
}
dc_lookup_real_nchat_by_contact_id(context, contact_id, &chat_id, &chat_id_blocked);
return chat_id_bloc... | projects/deltachat-core/rust/chat.rs | pub async fn lookup_by_contact(
context: &Context,
contact_id: ContactId,
) -> Result<Option<Self>> {
let Some(chat_id_blocked) = ChatIdBlocked::lookup_by_contact(context, contact_id).await?
else {
return Ok(None);
};
let chat_id = match chat_id_blocked.b... | pub struct Context {
pub(crate) inner: Arc<InnerContext>,
}
pub struct ChatId(u32);
pub(crate) struct ChatIdBlocked {
/// Chat ID.
pub id: ChatId,
/// Whether the chat is blocked, unblocked or a contact request.
pub blocked: Blocked,
}
impl ChatIdBlocked {
pub async fn lookup_by_contact(
... | use std::cmp;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::Duration;
use anyhow::{anyhow, bail, ensure, Context as _, Result};
use deltachat_contact_tools::{strip_rtlo_characters, ContactAddress};
use deltachat_derive::{FromSql, ToSql};
us... | projects__deltachat-core__rust__chat__.rs__function__8.txt |
projects/deltachat-core/c/dc_mimefactory.c | int dc_mimefactory_render(dc_mimefactory_t* factory)
{
struct mailimf_fields* imf_fields = NULL;
struct mailmime* message = NULL;
char* message_text = NULL;
char* message_text2 = NULL;
char* subject_str = NULL;
int afwd_email = 0;
int ... | projects/deltachat-core/rust/mimefactory.rs | pub async fn render(mut self, context: &Context) -> Result<RenderedEmail> {
let mut headers: MessageHeaders = Default::default();
let from = Address::new_mailbox_with_name(
self.from_displayname.to_string(),
self.from_addr.clone(),
);
let undisclosed_recipients ... | pub fn is_empty(&self) -> bool {
self.ids.is_empty()
}
async fn render_mdn(&mut self, context: &Context) -> Result<PartBuilder> {
// RFC 6522, this also requires the `report-type` parameter which is equal
// to the MIME subtype of the second body part of the multipart/report
//
... | use deltachat_contact_tools::ContactAddress;
use mailparse::{addrparse_header, MailHeaderMap};
use std::str;
use super::*;
use crate::chat::{
add_contact_to_chat, create_group_chat, remove_contact_from_chat, send_text_msg, ChatId,
ProtectionStatus,
};
use crate::chatlist::Chatlist;
use crate::consta... | projects__deltachat-core__rust__mimefactory__.rs__function__13.txt |
projects/deltachat-core/c/dc_msg.c | char* dc_msg_get_summarytext_by_raw(int type, const char* text, dc_param_t* param, int approx_characters, dc_context_t* context)
{
/* get a summary text, result must be free()'d, never returns NULL. */
char* ret = NULL;
char* prefix = NULL;
char* pathNfilename = NULL;
char* label = NULL;
char* value = NULL;
int ... | projects/deltachat-core/rust/summary.rs | async fn get_summary_text_without_prefix(&self, context: &Context) -> String {
let (emoji, type_name, type_file, append_text);
match self.viewtype {
Viewtype::Image => {
emoji = Some("📷");
type_name = Some(stock_str::image(context).await);
typ... | pub(crate) async fn voice_message(context: &Context) -> String {
translated(context, StockMessage::VoiceMessage).await
}
pub(crate) async fn image(context: &Context) -> String {
translated(context, StockMessage::Image).await
}
pub(crate) async fn video(context: &Context) -> String {
translated(context, St... | use std::borrow::Cow;
use std::fmt;
use std::str;
use crate::chat::Chat;
use crate::constants::Chattype;
use crate::contact::{Contact, ContactId};
use crate::context::Context;
use crate::message::{Message, MessageState, Viewtype};
use crate::mimeparser::SystemMessage;
use crate::stock_str;
use crate::stock_str::msg_rea... | projects__deltachat-core__rust__summary__.rs__function__6.txt |
projects/incubator-milagro-crypto/c/src/ecdh_support.c | void KDF2(int sha,const octet *z,const octet *p,int olen,octet *key)
{
/* NOTE: the parameter olen is the length of the output k in bytes */
char h[64];
octet H= {0,sizeof(h),h};
int cthreshold;
int hlen=sha;
OCT_empty(key);
cthreshold=ROUNDUP(olen,hlen);
for (int counter=1; counter<=... | projects/incubator-milagro-crypto/rust/src/ecdh.rs | pub fn kdf2(sha: usize, z: &[u8], p: Option<&[u8]>, olen: usize, k: &mut [u8]) {
// NOTE: the parameter olen is the length of the output K in bytes
let hlen = sha;
let mut lk = 0;
let mut cthreshold = olen / hlen;
if olen % hlen != 0 {
cthreshold += 1
}
for counter in 1..=cthreshol... | fn hashit(sha: usize, a: &[u8], n: usize, b: Option<&[u8]>, pad: usize, w: &mut [u8]) {
let mut r: [u8; 64] = [0; 64];
if sha == SHA256 {
let mut h = HASH256::new();
h.process_array(a);
if n > 0 {
h.process_num(n as i32)
}
if let Some(x) = b {
h.pr... | use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::rom;
use crate::aes;
use crate::aes::AES;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use crate::rand::RAND;
use super::*;
use crate::test_utils::*;
use crate::types::CurveType; | projects__incubator-milagro-crypto__rust__src__ecdh__.rs__function__4.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | unsign32 today(void)
{
/* return time in slots since epoch */
unsign32 ti=(unsign32)time(NULL);
return ti/(60*TIME_SLOT_MINUTES);
} | projects/incubator-milagro-crypto/rust/src/mpin256.rs | pub fn today() -> usize {
return (SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
/ (60 * 1440)) as usize;
} | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp8::ECP8;
use super::fp16::FP16;
use super::fp48::FP48;
use super::pair256;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
... | projects__incubator-milagro-crypto__rust__src__mpin256__.rs__function__3.txt | |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ALL(int sha,const octet *HID,const octet *xID,const octet *xCID,const octet *SEC,const octet *Y,const octet *R,const octet *W,octet *H)
{
char t[1284]; // assumes max modulus of 1024-bits
octet T= {0,sizeof(t),t};
OCT_joctet(&T,HID);
if (xCID!=NULL) OCT_joctet(&T,xCID);
else OCT_joctet(... | projects/incubator-milagro-crypto/rust/src/mpin192.rs | pub fn hash_all(
sha: usize,
hid: &[u8],
xid: &[u8],
xcid: Option<&[u8]>,
sec: &[u8],
y: &[u8],
r: &[u8],
w: &[u8],
h: &mut [u8],
) -> bool {
let mut tlen: usize = 0;
const RM: usize = big::MODBYTES as usize;
let mut t: [u8; 10 * RM + 4] = [0; 10 * RM + 4];
for i in ... | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp4::ECP4;
use super::fp24::FP24;
use super::fp8::FP8;
use super::pair192;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
us... | projects__incubator-milagro-crypto__rust__src__mpin192__.rs__function__27.txt |
projects/incubator-milagro-crypto/c/src/rsa_support.c | int OAEP_ENCODE(int sha,const octet *m,csprng *RNG,const octet *p,octet *f)
{
int slen;
int olen=f->max-1;
int mlen=m->len;
int hlen;
int seedlen;
char dbmask[MAX_RSA_BYTES];
char seed[64];
octet DBMASK= {0,sizeof(dbmask),dbmask};
octet SEED= {0,sizeof(seed),seed};
hlen=seedlen=... | projects/incubator-milagro-crypto/rust/src/rsa.rs | pub fn oaep_encode(sha: usize, m: &[u8], rng: &mut RAND, p: Option<&[u8]>, f: &mut [u8]) -> bool {
let olen = RFS - 1;
let mlen = m.len();
let hlen = sha;
let mut seed: [u8; 64] = [0; 64];
let seedlen = hlen;
if mlen > olen - hlen - seedlen - 1 {
return false;
}
let mut dbmas... | fn hashit(sha: usize, a: Option<&[u8]>, n: isize, w: &mut [u8]) {
if sha == SHA256 {
let mut h = HASH256::new();
if let Some(x) = a {
h.process_array(x);
}
if n >= 0 {
h.process_num(n as i32)
}
let hs = h.hash();
for i in 0..sha {
... | use super::big;
use super::ff;
use super::ff::FF;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use crate::rand::RAND;
use super::*;
use crate::test_utils::*; | projects__incubator-milagro-crypto__rust__src__rsa__.rs__function__7.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ALL(int sha,const octet *HID,const octet *xID,const octet *xCID,const octet *SEC,const octet *Y,const octet *R,const octet *W,octet *H)
{
char t[1284]; // assumes max modulus of 1024-bits
octet T= {0,sizeof(t),t};
OCT_joctet(&T,HID);
if (xCID!=NULL) OCT_joctet(&T,xCID);
else OCT_joctet(... | projects/incubator-milagro-crypto/rust/src/mpin.rs | pub fn hash_all(
sha: usize,
hid: &[u8],
xid: &[u8],
xcid: Option<&[u8]>,
sec: &[u8],
y: &[u8],
r: &[u8],
w: &[u8],
h: &mut [u8],
) -> bool {
let mut tlen: usize = 0;
const RM: usize = big::MODBYTES as usize;
let mut t: [u8; 10 * RM + 4] = [0; 10 * RM + 4];
for i in ... | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp2::ECP2;
use super::fp12::FP12;
use super::fp4::FP4;
use super::pair;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use c... | projects__incubator-milagro-crypto__rust__src__mpin__.rs__function__27.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | unsign32 today(void)
{
/* return time in slots since epoch */
unsign32 ti=(unsign32)time(NULL);
return ti/(60*TIME_SLOT_MINUTES);
} | projects/incubator-milagro-crypto/rust/src/mpin192.rs | pub fn today() -> usize {
return (SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
/ (60 * 1440)) as usize;
} | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp4::ECP4;
use super::fp24::FP24;
use super::fp8::FP8;
use super::pair192;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
us... | projects__incubator-milagro-crypto__rust__src__mpin192__.rs__function__3.txt | |
projects/incubator-milagro-crypto/c/src/pbc_support.c | unsign32 today(void)
{
/* return time in slots since epoch */
unsign32 ti=(unsign32)time(NULL);
return ti/(60*TIME_SLOT_MINUTES);
} | projects/incubator-milagro-crypto/rust/src/mpin.rs | pub fn today() -> usize {
return (SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
/ (60 * 1440)) as usize;
} | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp2::ECP2;
use super::fp12::FP12;
use super::fp4::FP4;
use super::pair;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use c... | projects__incubator-milagro-crypto__rust__src__mpin__.rs__function__3.txt | |
projects/incubator-milagro-crypto/c/src/ecdh_support.c | void PBKDF2(int sha,const octet *p,octet *s,int rep,int olen,octet *key)
{
int len;
int d=ROUNDUP(olen,sha);
char f[64];
char u[64];
octet F= {0,sizeof(f),f};
octet U= {0,sizeof(u),u};
OCT_empty(key);
for (int i=1; i<=d; i++)
{
len=s->len;
OCT_jint(s,i,4);
H... | projects/incubator-milagro-crypto/rust/src/ecdh.rs | pub fn pbkdf2(sha: usize, pass: &[u8], salt: &[u8], rep: usize, olen: usize, k: &mut [u8]) {
let mut d = olen / sha;
if olen % sha != 0 {
d += 1
}
let mut f: [u8; 64] = [0; 64];
let mut u: [u8; 64] = [0; 64];
let mut ku: [u8; 64] = [0; 64];
let mut s: [u8; 36] = [0; 36]; // Maximum s... | pub fn hmac(sha: usize, m: &[u8], k: &[u8], olen: usize, tag: &mut [u8]) -> bool {
// Input is from an octet m
// olen is requested output length in bytes. k is the key
// The output is the calculated tag
let mut b: [u8; 64] = [0; 64]; // Not good
let mut k0: [u8; 128] = [0; 128];
if olen < 4 {... | use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::rom;
use crate::aes;
use crate::aes::AES;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use crate::rand::RAND;
use super::*;
use crate::test_utils::*;
use crate::types::CurveType; | projects__incubator-milagro-crypto__rust__src__ecdh__.rs__function__5.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ALL(int sha,const octet *HID,const octet *xID,const octet *xCID,const octet *SEC,const octet *Y,const octet *R,const octet *W,octet *H)
{
char t[1284]; // assumes max modulus of 1024-bits
octet T= {0,sizeof(t),t};
OCT_joctet(&T,HID);
if (xCID!=NULL) OCT_joctet(&T,xCID);
else OCT_joctet(... | projects/incubator-milagro-crypto/rust/src/mpin256.rs | pub fn hash_all(
sha: usize,
hid: &[u8],
xid: &[u8],
xcid: Option<&[u8]>,
sec: &[u8],
y: &[u8],
r: &[u8],
w: &[u8],
h: &mut [u8],
) -> bool {
let mut tlen: usize = 0;
const RM: usize = big::MODBYTES as usize;
let mut t: [u8; 10 * RM + 4] = [0; 10 * RM + 4];
for i in ... | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp8::ECP8;
use super::fp16::FP16;
use super::fp48::FP48;
use super::pair256;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
... | projects__incubator-milagro-crypto__rust__src__mpin256__.rs__function__27.txt |
projects/incubator-milagro-crypto/c/src/hash.c | void HASH512_hash(hash512 *sh,char *hash)
{
/* pad message and finish - supply digest */
unsign64 len0;
unsign64 len1;
len0=sh->length[0];
len1=sh->length[1];
HASH512_process(sh,PAD);
while ((sh->length[0]%1024)!=896) HASH512_process(sh,ZERO);
sh->w[14]=len1;
sh->w[15]=len0;
HASH... | projects/incubator-milagro-crypto/rust/src/hash512.rs | pub fn hash(&mut self) -> [u8; 64] {
/* pad message and finish - supply digest */
let mut digest: [u8; 64] = [0; 64];
let len0 = self.length[0];
let len1 = self.length[1];
self.process(0x80);
while (self.length[0] % 1024) != 896 {
self.process(0)
}
... | fn transform(&mut self) {
/* basic transformation step */
for j in 16..80 {
self.w[j] = Self::theta1(self.w[j - 2])
.wrapping_add(self.w[j - 7])
.wrapping_add(Self::theta0(self.w[j - 15]))
.wrapping_add(self.w[j - 16]);
}
let mu... | use super::*; | projects__incubator-milagro-crypto__rust__src__hash512__.rs__function__15.txt |
projects/incubator-milagro-crypto/c/src/rand.c | void RAND_seed(csprng *rng,int rawlen,const char *raw)
{
/* initialise from at least 128 byte string of raw *
* random (keyboard?) input, and 32-bit time-of-day */
int i;
char digest[32];
uchar b[4];
hash256 sh;
rng->pool_ptr=0;
for (i=0; i<NK; i++) rng->ira[i]=0;
if (rawlen>0)
... | projects/incubator-milagro-crypto/rust/src/rand.rs | pub fn seed(&mut self, rawlen: usize, raw: &[u8]) {
/* initialise from at least 128 byte string of raw random entropy */
let mut b: [u8; 4] = [0; 4];
let mut sh = HASH256::new();
self.pool_ptr = 0;
for i in 0..RAND_NK {
self.ira[i] = 0
}
if rawlen > 0... | fn sirand(&mut self, seed: u32) {
let mut m: u32 = 1;
let mut sd = seed;
self.borrow = 0;
self.rndptr = 0;
self.ira[0] ^= sd;
for i in 1..RAND_NK {
/* fill initialisation vector */
let inn = (RAND_NV * i) % RAND_NK;
self.ira[inn] ^= m; ... | use crate::hash256::HASH256; | projects__incubator-milagro-crypto__rust__src__rand__.rs__function__7.txt |
projects/incubator-milagro-crypto/c/src/rsa_support.c | int OAEP_DECODE(int sha,const octet *p,octet *f)
{
int comp;
int x;
int t;
int i;
int k;
int olen=f->max-1;
int hlen;
int seedlen;
char dbmask[MAX_RSA_BYTES];
char seed[64];
char chash[64];
octet DBMASK= {0,sizeof(dbmask),dbmask};
octet SEED= {0,sizeof(seed),seed};
... | projects/incubator-milagro-crypto/rust/src/rsa.rs | pub fn oaep_decode(sha: usize, p: Option<&[u8]>, f: &mut [u8]) -> usize {
let olen = RFS - 1;
let hlen = sha;
let mut seed: [u8; 64] = [0; 64];
let seedlen = hlen;
let mut chash: [u8; 64] = [0; 64];
if olen < seedlen + hlen + 1 {
return 0;
}
let mut dbmask: [u8; RFS] = [0; RFS]... | fn hashit(sha: usize, a: Option<&[u8]>, n: isize, w: &mut [u8]) {
if sha == SHA256 {
let mut h = HASH256::new();
if let Some(x) = a {
h.process_array(x);
}
if n >= 0 {
h.process_num(n as i32)
}
let hs = h.hash();
for i in 0..sha {
... | use super::big;
use super::ff;
use super::ff::FF;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use crate::rand::RAND;
use super::*;
use crate::test_utils::*; | projects__incubator-milagro-crypto__rust__src__rsa__.rs__function__8.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ID(int sha,const octet *ID,octet *HID)
{
mhashit(sha,0,ID,HID);
} | projects/incubator-milagro-crypto/rust/src/mpin.rs | pub fn hash_id(sha: usize, id: &[u8], w: &mut [u8]) -> bool {
return hashit(sha, 0, id, w);
} | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp2::ECP2;
use super::fp12::FP12;
use super::fp4::FP4;
use super::pair;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use c... | projects__incubator-milagro-crypto__rust__src__mpin__.rs__function__6.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ID(int sha,const octet *ID,octet *HID)
{
mhashit(sha,0,ID,HID);
} | projects/incubator-milagro-crypto/rust/src/mpin256.rs | pub fn hash_id(sha: usize, id: &[u8], w: &mut [u8]) -> bool {
return hashit(sha, 0, id, w);
} | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp8::ECP8;
use super::fp16::FP16;
use super::fp48::FP48;
use super::pair256;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
... | projects__incubator-milagro-crypto__rust__src__mpin256__.rs__function__6.txt |
projects/incubator-milagro-crypto/c/src/rsa_support.c | int PKCS15(int sha,const octet *m,octet *w)
{
int olen=w->max;
int hlen=sha;
int idlen=19;
char h[64];
octet H= {0,sizeof(h),h};
if (olen<idlen+hlen+10) return 1;
hashit(sha,m,-1,&H);
OCT_empty(w);
OCT_jbyte(w,0x00,1);
OCT_jbyte(w,0x01,1);
OCT_jbyte(w,0xff,olen-idlen-hlen-3... | projects/incubator-milagro-crypto/rust/src/rsa.rs | pub fn pkcs15(sha: usize, m: &[u8], w: &mut [u8]) -> bool {
let olen = ff::FF_BITS / 8;
let hlen = sha;
let idlen = 19;
let mut b: [u8; 64] = [0; 64]; /* Not good */
if olen < idlen + hlen + 10 {
return false;
}
hashit(sha, Some(m), -1, &mut b);
for i in 0..w.len() {
w[... | fn hashit(sha: usize, a: Option<&[u8]>, n: isize, w: &mut [u8]) {
if sha == SHA256 {
let mut h = HASH256::new();
if let Some(x) = a {
h.process_array(x);
}
if n >= 0 {
h.process_num(n as i32)
}
let hs = h.hash();
for i in 0..sha {
... | use super::big;
use super::ff;
use super::ff::FF;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
use crate::rand::RAND;
use super::*;
use crate::test_utils::*; | projects__incubator-milagro-crypto__rust__src__rsa__.rs__function__6.txt |
projects/incubator-milagro-crypto/c/src/hash.c | void HASH384_hash(hash384 *sh,char *hash)
{
/* pad message and finish - supply digest */
unsign64 len0;
unsign64 len1;
len0=sh->length[0];
len1=sh->length[1];
HASH384_process(sh,PAD);
while ((sh->length[0]%1024)!=896) HASH384_process(sh,ZERO);
sh->w[14]=len1;
sh->w[15]=len0;
HASH... | projects/incubator-milagro-crypto/rust/src/hash384.rs | pub fn hash(&mut self) -> [u8; HASH_BYTES] {
/* pad message and finish - supply digest */
let mut digest: [u8; 48] = [0; HASH_BYTES];
let len0 = self.length[0];
let len1 = self.length[1];
self.process(0x80);
while (self.length[0] % 1024) != 896 {
self.process(... | fn transform(&mut self) {
// basic transformation step
for j in 16..80 {
self.w[j] = Self::theta1(self.w[j - 2])
.wrapping_add(self.w[j - 7])
.wrapping_add(Self::theta0(self.w[j - 15]))
.wrapping_add(self.w[j - 16]);
}
let mut a... | use super::*; | projects__incubator-milagro-crypto__rust__src__hash384__.rs__function__15.txt |
projects/incubator-milagro-crypto/c/src/hash.c | void HASH512_init(hash512 *sh)
{
/* re-initialise */
for (int i=0; i<80; i++) sh->w[i]=0;
sh->length[0]=sh->length[1]=0;
sh->h[0]=H0_512;
sh->h[1]=H1_512;
sh->h[2]=H2_512;
sh->h[3]=H3_512;
sh->h[4]=H4_512;
sh->h[5]=H5_512;
sh->h[6]=H6_512;
sh->h[7]=H7_512;
} | projects/incubator-milagro-crypto/rust/src/hash512.rs | pub fn init(&mut self) {
/* initialise */
for i in 0..64 {
self.w[i] = 0
}
self.length[0] = 0;
self.length[1] = 0;
self.h[0] = HASH512_H0;
self.h[1] = HASH512_H1;
self.h[2] = HASH512_H2;
self.h[3] = HASH512_H3;
self.h[4] = HASH5... | pub struct HASH512 {
length: [u64; 2],
h: [u64; 8],
w: [u64; 80],
}
const HASH512_H0: u64 = 0x6a09e667f3bcc908;
const HASH512_H1: u64 = 0xbb67ae8584caa73b;
const HASH512_H2: u64 = 0x3c6ef372fe94f82b;
const HASH512_H3: u64 = 0xa54ff53a5f1d36f1;
const HASH512_H4: u64 = 0x510e527fade682d1;
const HASH512_H5: u... | use super::*; | projects__incubator-milagro-crypto__rust__src__hash512__.rs__function__10.txt |
projects/incubator-milagro-crypto/c/src/hash.c | void HASH384_init(hash384 *sh)
{
/* re-initialise */
for (int i=0; i<80; i++) sh->w[i]=0;
sh->length[0]=sh->length[1]=0;
sh->h[0]=H8_512;
sh->h[1]=H9_512;
sh->h[2]=HA_512;
sh->h[3]=HB_512;
sh->h[4]=HC_512;
sh->h[5]=HD_512;
sh->h[6]=HE_512;
sh->h[7]=HF_512;
} | projects/incubator-milagro-crypto/rust/src/hash384.rs | pub fn init(&mut self) {
// initialise
for i in 0..64 {
self.w[i] = 0
}
self.length[0] = 0;
self.length[1] = 0;
self.h[0] = HASH384_H0;
self.h[1] = HASH384_H1;
self.h[2] = HASH384_H2;
self.h[3] = HASH384_H3;
self.h[4] = HASH384_... | pub struct HASH384 {
length: [u64; 2],
h: [u64; 8],
w: [u64; 80],
}
const HASH384_H0: u64 = 0xcbbb9d5dc1059ed8;
const HASH384_H1: u64 = 0x629a292a367cd507;
const HASH384_H2: u64 = 0x9159015a3070dd17;
const HASH384_H3: u64 = 0x152fecd8f70e5939;
const HASH384_H4: u64 = 0x67332667ffc00b31;
const HASH384_H5: u... | use super::*; | projects__incubator-milagro-crypto__rust__src__hash384__.rs__function__10.txt |
projects/incubator-milagro-crypto/c/src/rand.c | void RAND_clean(csprng *rng)
{
/* kill internal state */
int i;
rng->pool_ptr=rng->rndptr=0;
for (i=0; i<32; i++) rng->pool[i]=0;
for (i=0; i<NK; i++) rng->ira[i]=0;
rng->borrow=0;
} | projects/incubator-milagro-crypto/rust/src/rand.rs | pub fn clean(&mut self) {
self.pool_ptr = 0;
self.rndptr = 0;
for i in 0..32 {
self.pool[i] = 0
}
for i in 0..RAND_NK {
self.ira[i] = 0
}
self.borrow = 0;
} | pub struct RAND {
ira: [u32; RAND_NK], /* random number... */
rndptr: usize,
borrow: u32,
pool_ptr: usize,
pool: [u8; 32],
}
const RAND_NK: usize = 21; | use crate::hash256::HASH256; | projects__incubator-milagro-crypto__rust__src__rand__.rs__function__2.txt |
projects/incubator-milagro-crypto/c/src/pbc_support.c | void HASH_ID(int sha,const octet *ID,octet *HID)
{
mhashit(sha,0,ID,HID);
} | projects/incubator-milagro-crypto/rust/src/mpin192.rs | pub fn hash_id(sha: usize, id: &[u8], w: &mut [u8]) -> bool {
return hashit(sha, 0, id, w);
} | fn hashit(sha: usize, n: usize, id: &[u8], w: &mut [u8]) -> bool {
let mut r: [u8; 64] = [0; 64];
let mut didit = false;
if sha == SHA256 {
let mut h = HASH256::new();
if n > 0 {
h.process_num(n as i32)
}
h.process_array(id);
let hs = h.hash();
for... | use std::time::SystemTime;
use std::time::UNIX_EPOCH;
use super::big;
use super::big::Big;
use super::ecp;
use super::ecp::ECP;
use super::ecp4::ECP4;
use super::fp24::FP24;
use super::fp8::FP8;
use super::pair192;
use super::rom;
use crate::hash256::HASH256;
use crate::hash384::HASH384;
use crate::hash512::HASH512;
us... | projects__incubator-milagro-crypto__rust__src__mpin192__.rs__function__6.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.