comparison random.c @ 594:a98a2138364a

Improve capitalisation for all logged strings
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Feb 2011 15:50:30 +0000
parents c1e9c81d1d27
children 2d896267f16d
comparison
equal deleted inserted replaced
593:ea103e4476ce 594:a98a2138364a
62 #endif 62 #endif
63 63
64 #ifdef DROPBEAR_RANDOM_DEV 64 #ifdef DROPBEAR_RANDOM_DEV
65 readfd = open(DROPBEAR_RANDOM_DEV, O_RDONLY); 65 readfd = open(DROPBEAR_RANDOM_DEV, O_RDONLY);
66 if (readfd < 0) { 66 if (readfd < 0) {
67 dropbear_exit("couldn't open random device"); 67 dropbear_exit("Couldn't open random device");
68 } 68 }
69 #endif 69 #endif
70 70
71 #ifdef DROPBEAR_PRNGD_SOCKET 71 #ifdef DROPBEAR_PRNGD_SOCKET
72 readfd = connect_unix(DROPBEAR_PRNGD_SOCKET); 72 readfd = connect_unix(DROPBEAR_PRNGD_SOCKET);
73 73
74 if (readfd < 0) { 74 if (readfd < 0) {
75 dropbear_exit("couldn't open random device"); 75 dropbear_exit("Couldn't open random device");
76 } 76 }
77 /* todo - try various common locations */ 77 /* todo - try various common locations */
78 if (connect(readfd, (struct sockaddr*)&egdsock, 78 if (connect(readfd, (struct sockaddr*)&egdsock,
79 sizeof(struct sockaddr_un)) < 0) { 79 sizeof(struct sockaddr_un)) < 0) {
80 dropbear_exit("couldn't open random device"); 80 dropbear_exit("Couldn't open random device");
81 } 81 }
82 82
83 if (buflen > 255) 83 if (buflen > 255)
84 dropbear_exit("can't request more than 255 bytes from egd"); 84 dropbear_exit("Can't request more than 255 bytes from egd");
85 egdcmd[0] = 0x02; /* blocking read */ 85 egdcmd[0] = 0x02; /* blocking read */
86 egdcmd[1] = (unsigned char)buflen; 86 egdcmd[1] = (unsigned char)buflen;
87 if (write(readfd, egdcmd, 2) < 0) 87 if (write(readfd, egdcmd, 2) < 0)
88 dropbear_exit("can't send command to egd"); 88 dropbear_exit("Can't send command to egd");
89 #endif 89 #endif
90 90
91 /* read the actual random data */ 91 /* read the actual random data */
92 readpos = 0; 92 readpos = 0;
93 do { 93 do {
112 readlen = read(readfd, &buf[readpos], buflen - readpos); 112 readlen = read(readfd, &buf[readpos], buflen - readpos);
113 if (readlen <= 0) { 113 if (readlen <= 0) {
114 if (readlen < 0 && errno == EINTR) { 114 if (readlen < 0 && errno == EINTR) {
115 continue; 115 continue;
116 } 116 }
117 dropbear_exit("error reading random source"); 117 dropbear_exit("Error reading random source");
118 } 118 }
119 readpos += readlen; 119 readpos += readlen;
120 } while (readpos < buflen); 120 } while (readpos < buflen);
121 121
122 close (readfd); 122 close (readfd);