summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhshoexer <>2004-01-23 16:58:43 +0000
committerhshoexer <>2004-01-23 16:58:43 +0000
commite94374beadb2a55e7aaa0132dc8ec1c43c534d13 (patch)
treeb6814a948bdffdb739e1d43bc747d4f23c2d38bf
parentd38f1c5ae0451bf3eab12bb23992d2c4b064757a (diff)
downloadopenbsd-e94374beadb2a55e7aaa0132dc8ec1c43c534d13.tar.gz
openbsd-e94374beadb2a55e7aaa0132dc8ec1c43c534d13.tar.bz2
openbsd-e94374beadb2a55e7aaa0132dc8ec1c43c534d13.zip
evp api and manual page for acss
ok deraadt@ markus@
-rw-r--r--src/lib/libcrypto/evp/e_acss.c85
-rw-r--r--src/lib/libssl/src/crypto/evp/e_acss.c85
-rw-r--r--src/lib/libssl/src/doc/crypto/acss.pod66
3 files changed, 236 insertions, 0 deletions
diff --git a/src/lib/libcrypto/evp/e_acss.c b/src/lib/libcrypto/evp/e_acss.c
new file mode 100644
index 0000000000..f4e55f1030
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_acss.c
@@ -0,0 +1,85 @@
1/* $Id: e_acss.c,v 1.1 2004/01/23 16:58:43 hshoexer Exp $ */
2/*
3 * Copyright (c) 2004 The OpenBSD project
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef OPENSSL_NO_ACSS
19
20#include "cryptlib.h"
21#include <openssl/evp.h>
22#include <openssl/objects.h>
23#include "evp_locl.h"
24#include <openssl/acss.h>
25
26typedef struct {
27 ACSS_KEY ks;
28} EVP_ACSS_KEY;
29
30#define data(ctx) EVP_C_DATA(EVP_ACSS_KEY,ctx)
31
32static int acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
33 const unsigned char *iv, int enc);
34static int acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out,
35 const unsigned char *in, unsigned int inl);
36static int acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
37static const EVP_CIPHER acss_cipher = {
38 NID_undef,
39 1,5,0,
40 0,
41 acss_init_key,
42 acss_ciph,
43 NULL,
44 sizeof(EVP_ACSS_KEY),
45 NULL,
46 NULL,
47 acss_ctrl,
48 NULL
49};
50
51const
52EVP_CIPHER *EVP_acss(void)
53{
54 return(&acss_cipher);
55}
56
57static int
58acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
59 const unsigned char *iv, int enc)
60{
61 acss_setkey(&data(ctx)->ks,key,enc,ACSS_DATA);
62 return 1;
63}
64
65static int
66acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
67 unsigned int inl)
68{
69 acss(&data(ctx)->ks,inl,in,out);
70 return 1;
71}
72
73static int
74acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
75{
76 switch(type) {
77 case EVP_CTRL_SET_ACSS_MODE:
78 data(ctx)->ks.mode = arg;
79 return 1;
80
81 default:
82 return -1;
83 }
84}
85#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_acss.c b/src/lib/libssl/src/crypto/evp/e_acss.c
new file mode 100644
index 0000000000..f4e55f1030
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_acss.c
@@ -0,0 +1,85 @@
1/* $Id: e_acss.c,v 1.1 2004/01/23 16:58:43 hshoexer Exp $ */
2/*
3 * Copyright (c) 2004 The OpenBSD project
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef OPENSSL_NO_ACSS
19
20#include "cryptlib.h"
21#include <openssl/evp.h>
22#include <openssl/objects.h>
23#include "evp_locl.h"
24#include <openssl/acss.h>
25
26typedef struct {
27 ACSS_KEY ks;
28} EVP_ACSS_KEY;
29
30#define data(ctx) EVP_C_DATA(EVP_ACSS_KEY,ctx)
31
32static int acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
33 const unsigned char *iv, int enc);
34static int acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out,
35 const unsigned char *in, unsigned int inl);
36static int acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
37static const EVP_CIPHER acss_cipher = {
38 NID_undef,
39 1,5,0,
40 0,
41 acss_init_key,
42 acss_ciph,
43 NULL,
44 sizeof(EVP_ACSS_KEY),
45 NULL,
46 NULL,
47 acss_ctrl,
48 NULL
49};
50
51const
52EVP_CIPHER *EVP_acss(void)
53{
54 return(&acss_cipher);
55}
56
57static int
58acss_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
59 const unsigned char *iv, int enc)
60{
61 acss_setkey(&data(ctx)->ks,key,enc,ACSS_DATA);
62 return 1;
63}
64
65static int
66acss_ciph(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
67 unsigned int inl)
68{
69 acss(&data(ctx)->ks,inl,in,out);
70 return 1;
71}
72
73static int
74acss_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
75{
76 switch(type) {
77 case EVP_CTRL_SET_ACSS_MODE:
78 data(ctx)->ks.mode = arg;
79 return 1;
80
81 default:
82 return -1;
83 }
84}
85#endif
diff --git a/src/lib/libssl/src/doc/crypto/acss.pod b/src/lib/libssl/src/doc/crypto/acss.pod
new file mode 100644
index 0000000000..022a803be5
--- /dev/null
+++ b/src/lib/libssl/src/doc/crypto/acss.pod
@@ -0,0 +1,66 @@
1=pod
2
3=head1 NAME
4
5acss, acss_setkey - ACSS encryption
6
7=head1 SYNOPSIS
8
9 #include <openssl/acss.h>
10
11 void acss_setkey(ACSS_KEY *key, const unsigned char *data, int enc,
12 int mode);
13
14 void acss(ACSS_KEY *key, unsigned long len, const unsigned char *in,
15 unsigned char *out);
16
17=head1 DESCRIPTION
18
19This library implements the Alleged Content Scrambling System. It is believed
20to be interoperable with CSS of the DVD Copy Control Association.
21
22ACSS is a stream cipher with a fixed key length of 40 bit (5 byte).
23
24ACSS consists of a key setup phase and the actual encryption or decryption
25phase.
26
27acss_setkey() sets up the B<ACSS_KEY> B<key> using the 40 bit key at B<data>.
28If the flag B<enc> is set to B<1> B<key> will be used for encryption,
29otherwise for decryption. The integer B<mode> denotes the mode to use.
30Acceptible values are B<0> to B<3>. For any other value mode B<0> is used.
31
32acss() encrypts or decrypts the B<len> bytes of B<in> using B<key> and places
33the result at B<out>.
34
35Applications should use the higher level functions
36L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> etc. instead of calling the acss
37functions directly.
38
39=head1 RETURN VALUES
40
41None of the functions presented here return any value.
42
43=head1 NOTE
44
45ACSS is considered as an insecure cipher. Therefore, use of ACSS is
46discouraged.
47
48=head1 SEE ALSO
49
50RC4(3), arc4random(3)
51
52=head1 History
53
54A proprietary algorithm called CSS can be licensed from the DVD Copy Control
55Association (DVD CCA). CSS is considered a trade secret and is not patented.
56In October 1999 source code for CSS was posted anonymously to the LiViD
57mailing list. Since then, several implementations and mathematical
58descriptions of CSS are available and CSS has been subject to cryptanalysis.
59The DVD CCA has repeatedly failed to sue individuals for publishing such
60information about CSS.
61
62ACSS is a stream cipher written from scratch and believed to be interoperable
63with CSS.
64
65=cut
66