aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2014-01-23 15:20:00 -0800
committerDonald Stufft <donald@stufft.io>2014-01-23 15:20:00 -0800
commitf5e2b4d7cac6c2cf7137eb8b02efe25f59868c27 (patch)
treefd97253209bec719bfb44b12b47c37793833adeb /docs
parent56f81ea267be5339c6d17e19f68a1e8592e52582 (diff)
parentb32b491a9d976165a1b8ca8565a272ce46fc2730 (diff)
downloadcryptography-f5e2b4d7cac6c2cf7137eb8b02efe25f59868c27.tar.gz
cryptography-f5e2b4d7cac6c2cf7137eb8b02efe25f59868c27.tar.bz2
cryptography-f5e2b4d7cac6c2cf7137eb8b02efe25f59868c27.zip
Merge pull request #501 from alex/document-primitives
Document primitives
Diffstat (limited to 'docs')
-rw-r--r--docs/fernet.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/fernet.rst b/docs/fernet.rst
index 13295c0c..b0215e32 100644
--- a/docs/fernet.rst
+++ b/docs/fernet.rst
@@ -72,5 +72,22 @@ symmetric (also known as "secret key") authenticated cryptography.
See :meth:`Fernet.decrypt` for more information.
+Implementation
+--------------
+
+Fernet is built on top of a number of standard cryptographic primitives.
+Specifically it uses:
+
+* :class:`~cryptography.hazmat.primitives.ciphers.algorithms.AES` in
+ :class:`~cryptography.hazmat.primitives.ciphers.modes.CBC` mode with a
+ 128-bit key for encryption; using
+ :class:`~cryptography.hazmat.primitives.ciphers.PKCS7` padding.
+* :class:`~cryptography.hazmat.primitives.hmac.HMAC` using
+ :class:`~cryptography.hazmat.primitives.hashes.SHA256` for authentication.
+* Initialization vectors are generated using ``os.urandom()``.
+
+For complete details consult the `specification`_.
+
.. _`Fernet`: https://github.com/fernet/spec/
+.. _`specification`: https://github.com/fernet/spec/blob/master/Spec.md
px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #ffffff; } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * x86_64 -specific gdb stub routines
 * 
 * Copyright (C) 2007 Dan Doucette   ddoucette@teradici.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

#include <asm/debugger.h>

#define GDB_REG64(r) gdb_write_to_packet_hex(r, sizeof(u64), ctx)
#define GDB_REG32(r)  gdb_write_to_packet_hex(r, sizeof(u32), ctx)

void 
gdb_arch_read_reg_array(struct cpu_user_regs *regs, struct gdb_context *ctx)
{
    GDB_REG64(regs->rax);
    GDB_REG64(regs->rbx);
    GDB_REG64(regs->rcx);
    GDB_REG64(regs->rdx);
    GDB_REG64(regs->rsi);
    GDB_REG64(regs->rdi);
    GDB_REG64(regs->rbp);
    GDB_REG64(regs->rsp);

    GDB_REG64(regs->r8);
    GDB_REG64(regs->r9);
    GDB_REG64(regs->r10);
    GDB_REG64(regs->r11);
    GDB_REG64(regs->r12);
    GDB_REG64(regs->r13);
    GDB_REG64(regs->r14);
    GDB_REG64(regs->r15);

    GDB_REG64(regs->rip);
    GDB_REG32(regs->eflags);

    GDB_REG32(regs->cs);
    GDB_REG32(regs->ss);
    GDB_REG32(regs->ds);
    GDB_REG32(regs->es);
    GDB_REG32(regs->fs);
    GDB_REG32(regs->gs);

    gdb_send_packet(ctx);
}

void 
gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char* buf,
                         struct gdb_context *ctx)
{
    gdb_send_reply("", ctx);
}

void 
gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
                  struct gdb_context *ctx)
{
    switch (regnum)
    {
        case 0: GDB_REG64(regs->rax); break;
        case 1: GDB_REG64(regs->rbx); break;
        case 2: GDB_REG64(regs->rcx); break;
        case 3: GDB_REG64(regs->rdx); break;
        case 4: GDB_REG64(regs->rsi); break;
        case 5: GDB_REG64(regs->rdi); break;
        case 6: GDB_REG64(regs->rbp); break;
        case 7: GDB_REG64(regs->rsp); break;

        case 8: GDB_REG64(regs->r8); break;
        case 9: GDB_REG64(regs->r9); break;
        case 10: GDB_REG64(regs->r10); break;
        case 11: GDB_REG64(regs->r11); break;
        case 12: GDB_REG64(regs->r12); break;
        case 13: GDB_REG64(regs->r13); break;
        case 14: GDB_REG64(regs->r14); break;
        case 15: GDB_REG64(regs->r15); break;

        case 16: GDB_REG64(regs->rip); break;
        case 17: GDB_REG32(regs->rflags); break;
        case 18: GDB_REG32(regs->cs); break;
        case 19: GDB_REG32(regs->ss); break;
        case 20: GDB_REG32(regs->ds); break;
        case 21: GDB_REG32(regs->es); break;
        case 22: GDB_REG32(regs->fs); break;
        case 23: GDB_REG32(regs->gs); break;
        default:
            GDB_REG64(0xbaadf00ddeadbeef);
            break;
    }
    gdb_send_packet(ctx);
}

void 
gdb_arch_write_reg(unsigned long regnum, unsigned long val, 
                    struct cpu_user_regs *regs, struct gdb_context *ctx)
{
    switch (regnum)
    {
        case 0: regs->rax = val; break;
        case 1: regs->rbx = val; break;
        case 2: regs->rcx = val; break;
        case 3: regs->rdx = val; break;
        case 4: regs->rsi = val; break;
        case 5: regs->rdi = val; break;
        case 6: regs->rbp = val; break;
        case 7: regs->rsp = val; break;

        case 8: regs->r8 = val; break;
        case 9: regs->r9 = val; break;
        case 10: regs->r10 = val; break;
        case 11: regs->r11 = val; break;
        case 12: regs->r12 = val; break;
        case 13: regs->r13 = val; break;
        case 14: regs->r14 = val; break;
        case 15: regs->r15 = val; break;

        case 16: regs->rip = val; break;
        case 17: regs->rflags = (u32)val; break;
        case 18: regs->cs = (u16)val; break;
        case 19: regs->ss = (u16)val; break;
        case 20: regs->ds = (u16)val; break;
        case 21: regs->es = (u16)val; break;
        case 22: regs->fs = (u16)val; break;
        case 23: regs->gs = (u16)val; break;
        default:
            break;
    }
    gdb_send_reply("OK", ctx);
}

/*
 * Local variables:
 * mode: C
 * c-set-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * End:
 */