Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://devkitpro.svn.sourceforge.net/svnroot/devkitpro/trunk/libogc@1664 258c5a1a-4f63-435d-9564-e8f6d34ab52c
- Loading branch information
wntrmute
committed
Dec 19, 2006
1 parent
6afd3d1
commit a4ddbc4
Showing
18 changed files
with
4,262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef __LWP_HEAP_H__ | ||
#define __LWP_HEAP_H__ | ||
|
||
#include <gctypes.h> | ||
#include <asm.h> | ||
|
||
#define HEAP_BLOCK_USED 1 | ||
#define HEAP_BLOCK_FREE 0 | ||
|
||
#define HEAP_DUMMY_FLAG (0+HEAP_BLOCK_USED) | ||
|
||
#define HEAP_OVERHEAD (sizeof(u32)*2) | ||
#define HEAP_BLOCK_USED_OVERHEAD (sizeof(void*)*2) | ||
#define HEAP_MIN_SIZE (HEAP_OVERHEAD+sizeof(heap_block)) | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct _heap_block_st heap_block; | ||
struct _heap_block_st { | ||
u32 back_flag; | ||
u32 front_flag; | ||
heap_block *next; | ||
heap_block *prev; | ||
}; | ||
|
||
typedef struct _heap_iblock_st { | ||
u32 free_blocks; | ||
u32 free_size; | ||
u32 used_blocks; | ||
u32 used_size; | ||
} heap_iblock; | ||
|
||
typedef struct _heap_cntrl_st { | ||
heap_block *start; | ||
heap_block *final; | ||
|
||
heap_block *first; | ||
heap_block *perm_null; | ||
heap_block *last; | ||
u32 pg_size; | ||
u32 reserved; | ||
} heap_cntrl; | ||
|
||
u32 __lwp_heap_init(heap_cntrl *theheap,void *start_addr,u32 size,u32 pg_size); | ||
void* __lwp_heap_allocate(heap_cntrl *theheap,u32 size); | ||
BOOL __lwp_heap_free(heap_cntrl *theheap,void *ptr); | ||
u32 __lwp_heap_getinfo(heap_cntrl *theheap,heap_iblock *theinfo); | ||
|
||
#ifdef LIBOGC_INTERNAL | ||
#include <libogc/lwp_heap.inl> | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/**************************************************************************** | ||
* TinySMB-GC | ||
* | ||
* Nintendo Gamecube SaMBa implementation. | ||
* | ||
* Copyright softdev@tehskeen.com | ||
* | ||
* Authentication modules, LMhash and DES are | ||
* | ||
* Copyright Christopher R Hertel. | ||
* http://www.ubiqx.org | ||
* | ||
* You WILL find Ethereal, available from http://www.ethereal.com | ||
* invaluable for debugging each new SAMBA implementation. | ||
* | ||
* Recommended Reading | ||
* Implementing CIFS - Christopher R Hertel | ||
* SNIA CIFS Documentation - http://www.snia.org | ||
* | ||
* License: | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
****************************************************************************/ | ||
#ifndef __NBTSMB_H__ | ||
#define __NBTSMB_H__ | ||
|
||
#include <gctypes.h> | ||
|
||
/** | ||
* SMB Error codes | ||
*/ | ||
#define SMB_SUCCESS 0 | ||
#define SMB_ERROR -1 | ||
#define SMB_BAD_PROTOCOL -2 | ||
#define SMB_BAD_COMMAND -3 | ||
#define SMB_PROTO_FAIL -4 | ||
#define SMB_NOT_USER -5 | ||
#define SMB_BAD_KEYLEN -6 | ||
#define SMB_BAD_DATALEN -7 | ||
|
||
/** | ||
* SMB File Open Function | ||
*/ | ||
#define SMB_OF_OPEN 1 | ||
#define SMB_OF_TRUNCATE 2 | ||
#define SMB_OF_CREATE 16 | ||
|
||
/** | ||
* FileSearch | ||
*/ | ||
#define SMB_SRCH_DIRECTORY 16 | ||
#define SMB_SRCH_READONLY 1 | ||
#define SMB_SRCH_HIDDEN 2 | ||
#define SMB_SRCH_SYSTEM 4 | ||
#define SMB_SRCH_VOLUME 8 | ||
|
||
/** | ||
* SMB File Access Modes | ||
*/ | ||
#define SMB_OPEN_READING 0 | ||
#define SMB_OPEN_WRITING 1 | ||
#define SMB_OPEN_READWRITE 2 | ||
#define SMB_OPEN_COMPATIBLE 0 | ||
#define SMB_DENY_READWRITE 0x10 | ||
#define SMB_DENY_WRITE 0x20 | ||
#define SMB_DENY_READ 0x30 | ||
#define SMB_DENY_NONE 0x40 | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/*** | ||
* SMB Connection Handle | ||
*/ | ||
typedef u32 SMBCONN; | ||
|
||
/*** | ||
* SMB File Handle | ||
*/ | ||
typedef void* SMBFILE; | ||
|
||
/*** SMB_FILEENTRY | ||
SMB Long Filename Directory Entry | ||
***/ | ||
typedef struct | ||
{ | ||
u32 size_low; | ||
u32 size_high; | ||
u8 attributes; | ||
char name[256]; | ||
} SMBDIRENTRY; | ||
|
||
typedef struct | ||
{ | ||
char gcip[16]; | ||
char gwip[16]; | ||
char mask[16]; | ||
char smbip[16]; | ||
char smbuser[20]; | ||
char smbpwd[20]; | ||
char smbgcid[20]; | ||
char smbsvid[20]; | ||
char smbshare[20]; | ||
} SMBINFO; | ||
|
||
/** | ||
* Prototypes | ||
*/ | ||
|
||
/*** Session ***/ | ||
s32 SMB_Connect(SMBCONN *smbhndl, const char *user, const char *password, const char *client, const char *server, const char *share, const char *IP); | ||
void SMB_Close(SMBCONN smbhndl); | ||
|
||
/*** File Find ***/ | ||
s32 SMB_FindFirst(const char *filename, unsigned short flags, SMBDIRENTRY *sdir,SMBCONN smbhndl); | ||
s32 SMB_FindNext(SMBDIRENTRY *sdir,SMBCONN smbhndl); | ||
s32 SMB_FindClose(SMBCONN smbhndl); | ||
|
||
/*** File I/O ***/ | ||
SMBFILE SMB_OpenFile(const char *filename, unsigned short access, unsigned short creation,SMBCONN smbhndl); | ||
void SMB_CloseFile(SMBFILE sfid); | ||
s32 SMB_ReadFile(char *buffer, int size, int offset, SMBFILE sfid); | ||
s32 SMB_WriteFile(const char *buffer, int size, int offset, SMBFILE sfid); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#ifndef AUTH_DES_H | ||
#define AUTH_DES_H | ||
/* ========================================================================== ** | ||
* | ||
* DES.h | ||
* | ||
* Copyright: | ||
* Copyright (C) 2003, 2004 by Christopher R. Hertel | ||
* | ||
* Email: crh@ubiqx.mn.org | ||
* | ||
* $Id: des.h,v 1.1 2006-12-19 14:21:54 wntrmute Exp $ | ||
* | ||
* -------------------------------------------------------------------------- ** | ||
* | ||
* Description: | ||
* | ||
* Implements DES encryption, but not decryption. | ||
* DES is used to create LM password hashes and both LM and NTLM Responses. | ||
* | ||
* -------------------------------------------------------------------------- ** | ||
* | ||
* License: | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* -------------------------------------------------------------------------- ** | ||
* | ||
* Notes: | ||
* | ||
* This implementation was created by studying many existing examples | ||
* found in Open Source, in the public domain, and in various documentation. | ||
* The SMB protocol makes minimal use of the DES function, so this is a | ||
* minimal implementation. That which is not required has been removed. | ||
* | ||
* The SMB protocol uses the DES algorithm as a hash function, not an | ||
* encryption function. The auth_DEShash() implemented here is a one-way | ||
* function. The reverse is not implemented in this module. Also, there | ||
* is no attempt at making this either fast or efficient. There is no | ||
* need, as the auth)DEShash() function is used for generating the LM | ||
* Response from a 7-byte key and an 8-byte challenge. It is not intended | ||
* for use in encrypting large blocks of data or data streams. | ||
* | ||
* As stated above, this implementation is based on studying existing work | ||
* in the public domain or under Open Source (specifically LGPL) license. | ||
* The code, however, is written from scratch. Obviously, I make no claim | ||
* with regard to those earlier works (except to claim that I am grateful | ||
* to the previous implementors whose work I studied). See the list of | ||
* references below for resources I used. | ||
* | ||
* References: | ||
* I read through the libmcrypt code to see how they put the pieces | ||
* together. See: http://mcrypt.hellug.gr/ | ||
* Libmcrypt is available under the terms of the LGPL. | ||
* | ||
* The libmcrypt implementation includes the following credits: | ||
* written 12 Dec 1986 by Phil Karn, KA9Q; large sections adapted | ||
* from the 1977 public-domain program by Jim Gillogly | ||
* Modified for additional speed - 6 December 1988 Phil Karn | ||
* Modified for parameterized key schedules - Jan 1991 Phil Karn | ||
* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos | ||
* All modifications are placed under the license of libmcrypt. | ||
* | ||
* See also Phil Karn's privacy and security page: | ||
* http://www.ka9q.net/privacy.html | ||
* | ||
* I relied heavily upon: | ||
* Applied Cryptography, Second Edition: | ||
* Protocols, Algorithms, and Source Code in C | ||
* by Bruce Schneier. ISBN 0-471-11709-9, John Wiley & Sons, Inc., 1996 | ||
* Particularly Chapter 12. | ||
* | ||
* Here's one more DES resource, which I found quite helpful (aside from | ||
* the Clinton jokes): | ||
* http://www.aci.net/kalliste/des.htm | ||
* | ||
* Finally, the use of DES in SMB is covered in: | ||
* Implementing CIFS - the Common Internet File System | ||
* by your truly. ISBN 0-13-047116-X, Prentice Hall PTR., August 2003 | ||
* Section 15.3, in particular. | ||
* (Online at: http://ubiqx.org/cifs/SMB.html#SMB.8.3) | ||
* | ||
* ========================================================================== ** | ||
*/ | ||
|
||
//#include "auth_common.h" | ||
#include <stdio.h> | ||
typedef unsigned char uchar; | ||
typedef unsigned char uint8_t; | ||
|
||
/* -------------------------------------------------------------------------- ** | ||
* Functions: | ||
*/ | ||
|
||
uchar *auth_DESkey8to7( uchar *dst, const uchar *key ); | ||
/* ------------------------------------------------------------------------ ** | ||
* Compress an 8-byte DES key to its 7-byte form. | ||
* | ||
* Input: dst - Pointer to a memory location (minimum 7 bytes) to accept | ||
* the compressed key. | ||
* key - Pointer to an 8-byte DES key. See the notes below. | ||
* | ||
* Output: A pointer to the compressed key (same as <dst>) or NULL if | ||
* either <src> or <dst> were NULL. | ||
* | ||
* Notes: There are no checks done to ensure that <dst> and <key> point | ||
* to sufficient space. Please be carefull. | ||
* | ||
* The two pointers, <dst> and <key> may point to the same | ||
* memory location. Internally, a temporary buffer is used and | ||
* the results are copied back to <dst>. | ||
* | ||
* The DES algorithm uses 8 byte keys by definition. The first | ||
* step in the algorithm, however, involves removing every eigth | ||
* bit to produce a 56-bit key (seven bytes). SMB authentication | ||
* skips this step and uses 7-byte keys. The <auth_DEShash()> | ||
* algorithm in this module expects 7-byte keys. This function | ||
* is used to convert an 8-byte DES key into a 7-byte SMB DES key. | ||
* | ||
* ------------------------------------------------------------------------ ** | ||
*/ | ||
|
||
|
||
uchar *auth_DEShash( uchar *dst, const uchar *key, const uchar *src ); | ||
/* ------------------------------------------------------------------------ ** | ||
* DES encryption of the input data using the input key. | ||
* | ||
* Input: dst - Destination buffer. It *must* be at least eight bytes | ||
* in length, to receive the encrypted result. | ||
* key - Encryption key. Exactly seven bytes will be used. | ||
* If your key is shorter, ensure that you pad it to seven | ||
* bytes. | ||
* src - Source data to be encrypted. Exactly eight bytes will | ||
* be used. If your source data is shorter, ensure that | ||
* you pad it to eight bytes. | ||
* | ||
* Output: A pointer to the encrpyted data (same as <dst>). | ||
* | ||
* Notes: In SMB, the DES function is used as a hashing function rather | ||
* than an encryption/decryption tool. When used for generating | ||
* the LM hash the <src> input is the known value "KGS!@#$%" and | ||
* the key is derived from the password entered by the user. | ||
* When used to generate the LM or NTLM response, the <key> is | ||
* derived from the LM or NTLM hash, and the challenge is used | ||
* as the <src> input. | ||
* See: http://ubiqx.org/cifs/SMB.html#SMB.8.3 | ||
* | ||
* - This function is called "DEShash" rather than just "DES" | ||
* because it is only used for creating LM hashes and the | ||
* LM/NTLM responses. For all practical purposes, however, it | ||
* is a full DES encryption implementation. | ||
* | ||
* - This DES implementation does not need to be fast, nor is a | ||
* DES decryption function needed. The goal is to keep the | ||
* code small, simple, and well documented. | ||
* | ||
* - The input values are copied and refiddled within the module | ||
* and the result is not written to <dst> until the very last | ||
* step, so it's okay if <dst> points to the same memory as | ||
* <key> or <src>. | ||
* | ||
* ------------------------------------------------------------------------ ** | ||
*/ | ||
|
||
|
||
/* ========================================================================== */ | ||
#endif /* AUTH_DES_H */ |
Oops, something went wrong.