mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	raop: Add a MD5 hashing fuction
MD5 hashing will be needed during the authentication process. Original patch by Martin Blanchard. Patch splitted by Hajime Fujita <crisp.fujita@nifty.com>.
This commit is contained in:
		
							parent
							
								
									bac8a2ba66
								
							
						
					
					
						commit
						a33c04c0cc
					
				
					 2 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
					@ -30,12 +30,21 @@
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/err.h>
 | 
				
			||||||
 | 
					#include <openssl/md5.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulse/xmalloc.h>
 | 
					#include <pulse/xmalloc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulsecore/macro.h>
 | 
					#include <pulsecore/macro.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "raop_util.h"
 | 
					#include "raop_util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef MD5_DIGEST_LENGTH
 | 
				
			||||||
 | 
					#define MD5_DIGEST_LENGTH 16
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MD5_HASH_LENGTH (2*MD5_DIGEST_LENGTH)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BASE64_DECODE_ERROR 0xffffffff
 | 
					#define BASE64_DECODE_ERROR 0xffffffff
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char base64_chars[] =
 | 
					static const char base64_chars[] =
 | 
				
			||||||
| 
						 | 
					@ -141,3 +150,21 @@ int pa_raop_base64_decode(const char *str, void *data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return q - (unsigned char *) data;
 | 
					    return q - (unsigned char *) data;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_raop_md5_hash(const char *data, int len, char **str) {
 | 
				
			||||||
 | 
					    unsigned char d[MD5_DIGEST_LENGTH];
 | 
				
			||||||
 | 
					    char *s = NULL;
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(data);
 | 
				
			||||||
 | 
					    pa_assert(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MD5((unsigned char*) data, len, d);
 | 
				
			||||||
 | 
					    s = pa_xnew(char, MD5_HASH_LENGTH);
 | 
				
			||||||
 | 
					    for (i = 0; i < MD5_DIGEST_LENGTH; i++)
 | 
				
			||||||
 | 
					        sprintf(&s[2*i], "%02x", (unsigned int) d[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *str = s;
 | 
				
			||||||
 | 
					    s[MD5_HASH_LENGTH] = 0;
 | 
				
			||||||
 | 
					    return strlen(s);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,4 +30,6 @@
 | 
				
			||||||
int pa_raop_base64_encode(const void *data, int len, char **str);
 | 
					int pa_raop_base64_encode(const void *data, int len, char **str);
 | 
				
			||||||
int pa_raop_base64_decode(const char *str, void *data);
 | 
					int pa_raop_base64_decode(const char *str, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int pa_raop_md5_hash(const char *data, int len, char **str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue