VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/doc/html/Source Code.html
blob: 2942a9340bcf5e79ba960b20b0b20957cf402cca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>VeraCrypt - Free Open source disk encryption with strong security for the Paranoid</title>
<meta name="description" content="VeraCrypt is free open-source disk encryption software for Windows, Mac OS X and Linux. In case an attacker forces you to reveal the password, VeraCrypt provides plausible deniability. In contrast to file encryption, data encryption performed by VeraCrypt is real-time (on-the-fly), automatic, transparent, needs very little memory, and does not involve temporary unencrypted files."/>
<meta name="keywords" content="encryption, security"/>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div>                      
<a href="https://www.veracrypt.fr/en/Home.html"><img src="VeraCrypt128x128.png" alt="VeraCrypt"/></a>
</div>

<div id="menu">
	<ul>
	  <li><a href="Home.html">Home</a></li>
	  <li><a href="/code/">Source Code</a></li>
	  <li><a href="Downloads.html">Downloads</a></li>
	  <li><a class="active" href="Documentation.html">Documentation</a></li>
	  <li><a href="Donation.html">Donate</a></li>
	  <li><a href="https://sourceforge.net/p/veracrypt/discussion/" target="_blank">Forums</a></li>
	</ul>
</div>

<div>
<p>
<a href="Documentation.html">Documentation</a>           
<img src="arrow_right.gif" alt=">>" style="margin-top: 5px">
<a href="Technical%20Details.html">Technical Details</a>
<img src="arrow_right.gif" alt=">>" style="margin-top: 5px">
<a href="Source%20Code.html">Source Code</a>
</p></div>

<div class="wikidoc">
<h1>Source Code</h1>
<div style="text-align:left; margin-top:19px; margin-bottom:19px; padding-top:0px; padding-bottom:0px">
<p>VeraCrypt is open-source and free software. The complete source code of VeraCrypt (written in C, C&#43;&#43;, and assembly) is freely available for peer review at the following Git repositories:</p>
<p>
<ul>
  <li><a href="https://www.veracrypt.fr/code/" target="_blank">https://www.veracrypt.fr/code/</li>
  <li><a href="https://sourceforge.net/p/veracrypt/code/ci/master/tree/" target="_blank">https://sourceforge.net/p/veracrypt/code/ci/master/tree/</li>
  <li><a href="https://github.com/veracrypt/VeraCrypt" target="_blank">https://github.com/veracrypt/VeraCrypt</li>
  <li><a href="https://bitbucket.org/veracrypt/veracrypt/src" target="_blank">https://bitbucket.org/veracrypt/veracrypt/src</a></li>
</ul>
</p>
<p>The source code of each release can be downloaded from the same location as the release binaries.</p>
<p>&nbsp;</p>
</div>
</div><div class="ClearBoth"></div></body></html>
">*ctx))) == NULL) { zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return NULL; } zip_error_init(&ctx->error); ctx->key[0] = KEY0; ctx->key[1] = KEY1; ctx->key[2] = KEY2; decrypt(ctx, NULL, (const zip_uint8_t *)password, strlen(password), 1); if ((s2 = zip_source_layered(za, src, pkware_decrypt, ctx)) == NULL) { pkware_free(ctx); return NULL; } return s2; } static void decrypt(struct trad_pkware *ctx, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len, int update_only) { zip_uint16_t tmp; zip_uint64_t i; Bytef b; for (i = 0; i < len; i++) { b = in[i]; if (!update_only) { /* decrypt next byte */ tmp = (zip_uint16_t)(ctx->key[2] | 2); tmp = (zip_uint16_t)(((zip_uint32_t)tmp * (tmp ^ 1)) >> 8); b ^= (Bytef)tmp; } /* store cleartext */ if (out) out[i] = b; /* update keys */ ctx->key[0] = (zip_uint32_t)crc32(ctx->key[0] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; ctx->key[1] = (ctx->key[1] + (ctx->key[0] & 0xff)) * 134775813 + 1; b = (Bytef)(ctx->key[1] >> 24); ctx->key[2] = (zip_uint32_t)crc32(ctx->key[2] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; } } static int decrypt_header(zip_source_t *src, struct trad_pkware *ctx) { zip_uint8_t header[HEADERLEN]; struct zip_stat st; zip_int64_t n; unsigned short dostime, dosdate; if ((n = zip_source_read(src, header, HEADERLEN)) < 0) { _zip_error_set_from_source(&ctx->error, src); return -1; } if (n != HEADERLEN) { zip_error_set(&ctx->error, ZIP_ER_EOF, 0); return -1; } decrypt(ctx, header, header, HEADERLEN, 0); if (zip_source_stat(src, &st) < 0) { /* stat failed, skip password validation */ return 0; } _zip_u2d_time(st.mtime, &dostime, &dosdate); if (header[HEADERLEN - 1] != st.crc >> 24 && header[HEADERLEN - 1] != dostime >> 8) { zip_error_set(&ctx->error, ZIP_ER_WRONGPASSWD, 0); return -1; } return 0; } static zip_int64_t pkware_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { struct trad_pkware *ctx; zip_int64_t n; ctx = (struct trad_pkware *)ud; switch (cmd) { case ZIP_SOURCE_OPEN: if (decrypt_header(src, ctx) < 0) return -1; return 0; case ZIP_SOURCE_READ: if ((n = zip_source_read(src, data, len)) < 0) { _zip_error_set_from_source(&ctx->error, src); return -1; } decrypt((struct trad_pkware *)ud, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n, 0); return n; case ZIP_SOURCE_CLOSE: return 0; case ZIP_SOURCE_STAT: { zip_stat_t *st; st = (zip_stat_t *)data; st->encryption_method = ZIP_EM_NONE; st->valid |= ZIP_STAT_ENCRYPTION_METHOD; /* TODO: deduce HEADERLEN from size for uncompressed */ if (st->valid & ZIP_STAT_COMP_SIZE) st->comp_size -= HEADERLEN; return 0; } case ZIP_SOURCE_SUPPORTS: return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, -1); case ZIP_SOURCE_ERROR: return zip_error_to_data(&ctx->error, data, len); case ZIP_SOURCE_FREE: pkware_free(ctx); return 0; default: zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); return -1; } } static void pkware_free(struct trad_pkware *ctx) { free(ctx); }