src/treesutil.c
/**
 * writes file
 * FILE* in must have been opened with open_trees_file
 */
writes file
FILE* in must have been opened with open_trees_file
writes file FILE * in must have been opened with open_trees_file
static void
decrypttreesfile(user_t *user, const char *outpath, FILE *in)
{
    FILE *out;
    size_t ret;
    unsigned char inbuf[ENCRYPTED_CHUNK_SIZE];
    unsigned char outbuf[CHUNK_SIZE];
    out = fopen(outpath, "w");
    if(out == NULL) {
        die(true, "error opening output file: %s", strerror(errno));
    }
    while((ret = fread(inbuf, 1, sizeof inbuf, in)) > 0) {
        if(ret < crypto_box_SEALBYTES) {
            die(false, "invalid chunk; too short");
        }
        if(crypto_box_seal_open(outbuf, inbuf,
                                ret, user->pubkey, user->privkey) != 0) {
            die(false, "unable to decrypt chunk");
        }
        fwrite(outbuf, 1, ret - crypto_box_SEALBYTES, out);
    }
    if(feof(out)) {
        die(false, "error reading file: %s", strerror(ferror(in)));
    }
    fclose(out);
}
static void decrypttreesfile ( user_t * user , const char * outpath , FILE * in ) { FILE * out ; size_t ret ; unsigned char inbuf [ ENCRYPTED_CHUNK_SIZE ] ; unsigned char outbuf [ CHUNK_SIZE ] ; out = fopen ( outpath , " " ) ; if ( out == NULL ) { die ( true , " " , strerror ( errno ) ) ; } while ( ( ret = fread ( inbuf , 1 , sizeof inbuf , in ) ) > 0 ) { if ( ret < crypto_box_SEALBYTES ) { die ( false , " " ) ; } if ( crypto_box_seal_open ( outbuf , inbuf , ret , user -> pubkey , user -> privkey ) != 0 ) { die ( false , " " ) ; } fwrite ( outbuf , 1 , ret - crypto_box_SEALBYTES , out ) ; } if ( feof ( out ) ) { die ( false , " " , strerror ( ferror ( in ) ) ) ; } fclose ( out ) ; }
writes file
 FILE* in must have been opened with open_trees_file
writes file FILE * in must have been opened with open_trees_file