aboutsummaryrefslogtreecommitdiffstats
path: root/docs/faq.rst
blob: 0b7bdce424e433655a7b613d1c291384cb079710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Frequently asked questions
==========================

How does ``cryptography`` compare to NaCl (Networking and Cryptography Library)?
--------------------------------------------------------------------------------

While ``cryptography`` and `NaCl`_ both share the goal of making cryptography
easier, and safer, to use for developers, ``cryptography`` is designed to be a
general purpose library, interoperable with existing systems, while NaCl
features a collection of hand selected algorithms.

``cryptography``'s :ref:`recipes <cryptography-layout>` layer has similar goals
to NaCl.

If you prefer NaCl's design, we highly recommend `PyNaCl`_.

.. _`NaCl`: http://nacl.cr.yp.to/
.. _`PyNaCl`: https://pynacl.readthedocs.org
t .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 */
/******************************************************************************
 * string.c
 * 
 * These provide something for compiler-emitted string operations to link
 * against.
 */

#include <xen/config.h>
#include <xen/lib.h>

#undef memcpy
void *memcpy(void *dest, const void *src, size_t n)
{
    long d0, d1, d2;

    asm volatile (
#ifdef __i386__
        "   rep movsl        ; "
#else
        "   rep movsq        ; "
        "   testb $4,%b4     ; "
        "   je 0f            ; "
        "   movsl            ; "
        "0:                  ; "
#endif
        "   testb $2,%b4     ; "
        "   je 1f            ; "
        "   movsw            ; "
        "1: testb $1,%b4     ; "
        "   je 2f            ; "
        "   movsb            ; "
        "2:                    "
        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
        : "0" (n/sizeof(long)), "q" (n), "1" (dest), "2" (src)
        : "memory");

    return dest;
}

#undef memset
void *memset(void *s, int c, size_t n)
{
    long d0, d1;

    asm volatile (
        "rep stosb"
        : "=&c" (d0), "=&D" (d1)
        : "a" (c), "1" (s), "0" (n)
        : "memory");

    return s;
}

#undef memmove
void *memmove(void *dest, const void *src, size_t n)
{
    long d0, d1, d2;
 
    if ( dest < src )
        return memcpy(dest, src, n);

    asm volatile (
        "   std         ; "
        "   rep movsb   ; "
        "   cld           "
        : "=&c" (d0), "=&S" (d1), "=&D" (d2)
        : "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)
        : "memory");

    return dest;
}

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