XRootD
Loading...
Searching...
No Matches
XrdCryptoLite.hh
Go to the documentation of this file.
1
#ifndef __XRDCRYPTOLITE_H__
2
#define __XRDCRYPTOLITE_H__
3
/******************************************************************************/
4
/* */
5
/* X r d C r y p t o L i t e . h h */
6
/* */
7
/* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/* */
12
/* This file is part of the XRootD software suite. */
13
/* */
14
/* XRootD is free software: you can redistribute it and/or modify it under */
15
/* the terms of the GNU Lesser General Public License as published by the */
16
/* Free Software Foundation, either version 3 of the License, or (at your */
17
/* option) any later version. */
18
/* */
19
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22
/* License for more details. */
23
/* */
24
/* You should have received a copy of the GNU Lesser General Public License */
25
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27
/* */
28
/* The copyright holder's institutional names and contributor's names may not */
29
/* be used to endorse or promote products derived from this software without */
30
/* specific prior written permission of the institution or contributor. */
31
/******************************************************************************/
32
33
// This abstract class defines a very simple interface to encryption methods.
34
// CryptoLite provides a naive interface to stream cryptographic algorithms
35
// that include decryption validation. Use XrdCryptoBasic and it's derived
36
// classes for full-featured cryptogrophy.
37
//
38
39
class
XrdCryptoLite
40
{
41
public
:
42
43
// Create() creates a new CryptoLite object that implements the specified
44
// cryptography (see below). It returns a pointer to the object or a
45
// null pointer if not successful (e.g., unsupported). When creating a
46
// crypto object you may associate an arbitrary type code with an
47
// instance of that object which Type() will simply echo back.
48
49
// Supported names:
50
// bf32 Blowfish with CRC32 validation.
51
//
52
static
XrdCryptoLite
*
53
Create
(
int
&rc,
// errno when Create(...) == 0
54
const
char
*Name,
// Crypto name
55
const
char
Type
=
'\0'
);
// Crypto type (assigned)
56
57
// Decrypt() decrypts src and, if successful, returns the number of bytes
58
// placed in dst. Otherwise, -errno is returned (which may be 0).
59
// Requirements: srclen >= dstlen > 0
60
//
61
virtual
int
Decrypt
(
const
char
*key,
// Decryption key
62
int
keyLen,
// Decryption key byte length
63
const
char
*src,
// Buffer to be decrypted
64
int
srcLen,
// Bytes length of src buffer
65
char
*dst,
// Buffer to hold decrypted result
66
int
dstLen)=0;
// Bytes length of dst buffer
67
68
// Encrypt() encrypts src and, if successful, returns the number of bytes
69
// placed in dst. Otherwise, -errno is returned (which may be 0).
70
// Requirements: 0 < srclen <= (dstlen + Overhead())
71
//
72
virtual
int
Encrypt
(
const
char
*key,
// Encryption key
73
int
keyLen,
// Encryption key byte length
74
const
char
*src,
// Buffer to be encrypted
75
int
srcLen,
// Bytes length of src buffer
76
char
*dst,
// Buffer to hold encrypted result
77
int
dstLen)=0;
// Bytes length of dst buffer
78
79
// Overhead() returns the number of *extra* bytes required for the dst buffer,
80
// as specified when the actual implementation was instantiated.
81
// Hence, we can provide an implementation for this method.
82
//
83
virtual
int
Overhead
() {
return
Extra
;}
84
85
// Type() simply returns the encyption type code assigned to this object when
86
// its actual implementation was instantiated. Hence, we can provide an
87
// implementation for this method.
88
//
89
virtual
char
Type
() {
return
myType
;}
90
91
XrdCryptoLite
(
char
deType,
int
ovhd=8) :
Extra
(ovhd),
myType
(deType) {}
92
virtual
~XrdCryptoLite
() {}
93
94
protected
:
95
96
int
Extra
;
97
char
myType
;
98
};
99
#endif
Create
bool Create
Definition
XrdSecpwdSrvAdmin.cc:176
XrdCryptoLite::XrdCryptoLite
XrdCryptoLite(char deType, int ovhd=8)
Definition
XrdCryptoLite.hh:91
XrdCryptoLite::Encrypt
virtual int Encrypt(const char *key, int keyLen, const char *src, int srcLen, char *dst, int dstLen)=0
XrdCryptoLite::Overhead
virtual int Overhead()
Definition
XrdCryptoLite.hh:83
XrdCryptoLite::Decrypt
virtual int Decrypt(const char *key, int keyLen, const char *src, int srcLen, char *dst, int dstLen)=0
XrdCryptoLite::Type
virtual char Type()
Definition
XrdCryptoLite.hh:89
XrdCryptoLite::myType
char myType
Definition
XrdCryptoLite.hh:97
XrdCryptoLite::Extra
int Extra
Definition
XrdCryptoLite.hh:96
XrdCryptoLite::~XrdCryptoLite
virtual ~XrdCryptoLite()
Definition
XrdCryptoLite.hh:92
XrdCrypto
XrdCryptoLite.hh
Generated by
1.13.1