File: dlp.h

package info (click to toggle)
clamav 0.98.7%2Bdfsg-0%2Bdeb6u2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 60,204 kB
  • ctags: 49,129
  • sloc: cpp: 267,090; ansic: 152,211; sh: 35,196; python: 2,630; makefile: 2,220; perl: 1,690; pascal: 1,218; lisp: 184; csh: 117; xml: 38; asm: 32; exp: 4
file content (136 lines) | stat: -rw-r--r-- 4,678 bytes parent folder | download | duplicates (4)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* 
 *  Simple library to detect and validate SSN and Credit Card numbers.
 *
 *  Copyright (C) 2007-2008 Sourcefire, Inc.
 *
 *  Authors: Martin Roesch <roesch@sourcefire.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  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., 51 Franklin Street, Fifth Floor, Boston,
 *  MA 02110-1301, USA.
 */

#ifndef __DLP_H_
#define __DLP_H_

#include <stdio.h>

/* these macros define the SSN string format to search for */
#define SSN_FORMAT_HYPHENS    0     /* xxx-yy-zzzz */
#define SSN_FORMAT_STRIPPED   1     /* xxxyyzzzz */

/*
 * will check if a valid credit card number exists within the 
 * first 16 bytes of the supplied buffer.  Validation supplied
 * via the Luhn algorithm.
 * Params:
 *      buffer => data buffer to be validated.
 *      length => length of supplied buffer.  Values greater than 16 are
 *                truncated to 16.  Values less than 13 are rejected. 
 * Returns:
 *      1 on a find, 0 on a miss
 */
int dlp_is_valid_cc(const unsigned char *buffer, int length);

/* Searches the supplied buffer for credit card numbers and returns
 * the number of CC's found.
 * Params:
 *      buffer => data buffer to be analyzed.
 *      length => length of buffer.  
 * Returns:
 *      Count of detected CC #'s.
 */
int dlp_get_cc_count(const unsigned char *buffer, int length);

/* Searches the supplied buffer for CC #'s.  Bails out as soon as a 
 * validated number is detected.
 * Params:
 *      buffer => data buffer to be analyzed.
 *      length => length of buffer.
 * Returns:
 *      1 on detect, 0 on fail
 */
int dlp_has_cc(const unsigned char *buffer, int length);

/* Checks the supplied buffer for a valid SSN number.  Validation
 * is supplied via area and group number validation.  Valid numbers
 * which are not in circulation (666 series, 000 series) are NOT
 * detected, only numbers that can be valid in the real world.  Searches
 * only the first 11 or 9 bytes (based on the selected format)!
 * Params:
 *      buffer => buffer to be validated
 *      length => length of buffer to validate
 * Returns:
 *      1 on detect, 0 on failure
 */
int dlp_is_valid_ssn(const unsigned char *buffer, int length, int format);

/* Searches the supplied buffer for valid SSNs.  Note that this function
 * is effectively searching the buffer TWICE looking for the hyphenated and
 * stripped forms of the SSN.  There will be a performance impact!
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      Count of SSNs in the supplied buffer
 */
int dlp_get_ssn_count(const unsigned char *buffer, int length);

/* Searches the supplied buffer for valid SSNs formatted as xxxyyzzzz.
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      Count of SSNs in the supplied buffer.
 */
int dlp_get_stripped_ssn_count(const unsigned char *buffer, int length);

/* Searches the supplied buffer for valid SSNs formatted as xxx-yy-zzzz.
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      Count of SSNs in the supplied buffer.
 */
int dlp_get_normal_ssn_count(const unsigned char *buffer, int length);

/* Searches the supplied buffer for a SSN in any format.  This searches the
 * buffer twice for both the stripped and hyphenated versions of an SSN so
 * there will be a performance impact!
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      1 on detect, 0 on fail
 */
int dlp_has_ssn(const unsigned char *buffer, int length);

/* Searches the supplied buffer for a SSN in the stripped xxxyyzzzz format.
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      1 on detect, 0 on fail
 */
int dlp_has_stripped_ssn(const unsigned char *buffer, int length);

/* Searches the supplied buffer for a SSN in the normal xxx-yy-zzzz format.
 * Params:
 *      buffer => buffer to search
 *      length => length of the buffer
 * Returns:
 *      1 on detect, 0 on fail
 */
int dlp_has_normal_ssn(const unsigned char *buffer, int length);

#endif  /* __DLP_H_ */