* Function checks if the given buffer is already 16 bytes aligned. * If it is there is no need to allocate new buffer. * If it isn't, new buffer is allocated. */
| 165 | * If it isn't, new buffer is allocated. |
| 166 | */ |
| 167 | static u_char * |
| 168 | padlock_cipher_alloc(struct cryptop *crp, int *allocated) |
| 169 | { |
| 170 | u_char *addr; |
| 171 | |
| 172 | addr = crypto_contiguous_subsegment(crp, crp->crp_payload_start, |
| 173 | crp->crp_payload_length); |
| 174 | if (((uintptr_t)addr & 0xf) == 0) { /* 16 bytes aligned? */ |
| 175 | *allocated = 0; |
| 176 | return (addr); |
| 177 | } |
| 178 | |
| 179 | *allocated = 1; |
| 180 | addr = malloc(crp->crp_payload_length + 16, M_PADLOCK, M_NOWAIT); |
| 181 | return (addr); |
| 182 | } |
| 183 | |
| 184 | int |
| 185 | padlock_cipher_process(struct padlock_session *ses, struct cryptop *crp, |
no test coverage detected